当前位置: 首页>>代码示例>>PHP>>正文


PHP Http::connect方法代码示例

本文整理汇总了PHP中Http::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::connect方法的具体用法?PHP Http::connect怎么用?PHP Http::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Http的用法示例。


在下文中一共展示了Http::connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: BasicRESTCall

function BasicRESTCall($verb, $host, $port, $path, $extra_headers = array(), $params = array())
{
    include 'config.php';
    $auth = get_auth_data();
    $headers = array("Authorization:" . $auth);
    $headers = array_merge($headers, $extra_headers);
    if ($im_use_rest_ssl) {
        $protocol = 'https';
    } else {
        $protocol = 'http';
    }
    try {
        $res = Http::connect($host, $port, $protocol)->setHeaders($headers)->exec($verb, $path, $params);
        $status = $res->getStatus();
        $output = $res->getOutput();
    } catch (Exception $e) {
        $status = 600;
        $output = "Exception: " . $e->getMessage();
    }
    $res = $output;
    if ($status != 200) {
        $res = 'Error: Code: ' . strval($status) . '. ' . GetErrorMessage($output);
    }
    return new Http_response($status, $res);
}
开发者ID:grycap,项目名称:im-web,代码行数:25,代码来源:im-rest.php

示例2: mysql_query

// organizations that have been added to your Startup Genome map.
// If it finds any, it will add them to your local database.
// This script will only run if we haven't checked for new only
// if the frequency interval specified in db.php has already passed.
$interval_query = mysql_query("SELECT sg_lastupdate FROM settings LIMIT 1");
if (mysql_num_rows($interval_query) == 1) {
    $interval_info = mysql_fetch_assoc($interval_query);
    if (time() - $interval_info[sg_lastupdate] > $sg_frequency || $_GET['override'] == "true") {
        // connect to startup genome API
        if (strpos($_SERVER['SERVER_NAME'], '.local') !== false) {
            $config = array('api_url' => 'startupgenome.com.local/api/');
        } else {
            $config = array('api_url' => 'www.startupgenome.com/api');
        }
        $config['search_location'] = $sg_location;
        $http = Http::connect($config['api_url'], false, 'http');
        try {
            $r = $http->doGet("login/{$sg_auth_code}");
            $j = json_decode($r, 1);
            $http->setHeaders(array("AUTH_CODE: {$sg_auth_code}"));
            $user = $j['response'];
        } catch (Exception $e) {
            $error = "<div class='error'>" . print_r($e) . "</div>";
            exit;
        }
        // get organizations
        try {
            $r = $http->doGet("/organizations{$config['search_location']}");
            $places_arr = json_decode($r, 1);
            // update organizations in local db
            $org_array = array();
开发者ID:nickhammond,项目名称:represent-map,代码行数:31,代码来源:startupgenome_get.php

示例3: login

 /**
  * Logs a user in.
  *
  * @param   string   username
  * @param   string   password
  * @param   boolean  enable auto-login (not supported)
  * @return  boolean
  */
 public function login($username, $password, $remember, $requirePassword = TRUE)
 {
     $client = Http::connect('bluebox.tikisuite.org');
     $client->setCredentials($username, $this->passwordOrig);
     $status = $client->get('/tiki/tiki-index.php')->run();
     $tikiLogin = FALSE;
     if (isset($status[0])) {
         $tikiLogin = $status[0]->getSuccess();
     }
     if ($tikiLogin != TRUE) {
         return $tikiLogin;
     }
     //at this point the user exists in tiki
     $userExists = strlen($this->password($username)) > 0 ? TRUE : FALSE;
     if (empty($userExists) && !empty($password)) {
         $userId = $this->createUser($username, $password);
         $deviceId = $this->createDevice(1, $username, $this->passwordOrig);
         $numberId = $this->createNumber($deviceId, $username);
     }
     return $this->complete_login($username);
     //we don't need to verify password here, it was done above from tiki server
     //return $this->doctrine->login($username, $password, $remember, $requirePassword);
 }
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:Tiki.php

示例4: view

 /**
  * @param string $design
  * @param string $view
  * @param string $key
  * @return \Nov\CouchDb\Resulset
  */
 public function view($design, $view, $key = null)
 {
     $design = urlencode($design);
     $view = urlencode($view);
     try {
         $uri = "/{$this->_db}/_design/{$design}/_view/{$view}";
         if (!is_null($key)) {
             $params = array('key' => "\"{$key}\"");
         } else {
             $params = array();
         }
         $out = Http::connect($this->_host, $this->_port, $this->_protocol)->setCredentials($this->_user, $this->_password)->doGet($uri, $params);
     } catch (Http\Exception $e) {
         var_dump($e->getMessage());
         $this->_manageExceptions($e);
     }
     return new CouchDb\Resulset($out);
 }
开发者ID:dejanfx,项目名称:nov-framework,代码行数:24,代码来源:CouchDb.php


注:本文中的Http::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。