本文整理汇总了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);
}
示例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();
示例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);
}
示例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);
}