本文整理汇总了PHP中Curl::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::fetch方法的具体用法?PHP Curl::fetch怎么用?PHP Curl::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::fetch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
throw new Exception("I couldn't fetch the response.");
}
printf("Single request: Success: %s\n", $response);
printf("I downloaded %n bytes!\n", $curl->info('size_download'));
// Now we'll test the parallel processor
/**
* Let's fetch Yahoo
*/
$y = new Curl("http://www.yahoo.com/");
/**
* And let's grab Google, too
*/
$g = new Curl("http://www.google.com/");
/**
* Create a CurlParallel object
*/
$m = new CurlParallel($y, $g);
$m->exec();
if (strlen($g->fetch()) && strlen($y->fetch())) {
printf("Parallel requests: Success!");
} else {
throw new Exception("Could not run in parallel.");
}
} catch (Exception $e) {
// There was a problem! What happened?
printf("Oh Noes!\n");
printf("%s\n", $e->getMessage());
if ($curl) {
printf("cURL error: %s\n", $curl->errno());
}
}
示例2: globalAuth
public function globalAuth()
{
global $_USERID;
$url = ROOT_AUTH . "authentication/";
$headers = array("Api-Code: " . API_NAME);
$headers[] = "Authorization: " . str_replace("Global ", "", $this->request->headers->authorization());
$options = array(CURLOPT_URL => $url, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_HTTPHEADER => $headers);
$curl = new Curl();
$result = $curl->fetch($options);
if ($result->code < 300) {
$this->permissions = $result->body->permissions;
$_USERID = $result->body->userId;
return true;
} else {
$this->response->status($result->code);
}
}
示例3: fetchXML
public function fetchXML($url)
{
if (function_exists('apc_fetch')) {
$expiry = apc_fetch('expiry');
if (!$expiry || $expiry < time()) {
apc_clear_cache();
apc_clear_cache('user');
apc_store('expiry', time() + config('apc.expiry'));
}
if (apc_fetch($url)) {
$results = apc_fetch($url, $results);
} else {
$results = Curl::fetch($url, true);
apc_store($url, $results);
}
} else {
$results = Curl::fetch($url, true);
}
$string = simplexml_load_string($results);
if ($string === FALSE) {
Debug::error("Not XML");
return false;
} else {
$oXML = new SimpleXMLElement($results);
return $oXML;
}
}