當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Curl::fetch方法代碼示例

本文整理匯總了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());
    }
}
開發者ID:jsocol,項目名稱:oocurl,代碼行數:31,代碼來源:test.php

示例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);
     }
 }
開發者ID:irwtdvoys,項目名稱:bolt,代碼行數:17,代碼來源:Api.php

示例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;
     }
 }
開發者ID:nickbreslin,項目名稱:Assembler,代碼行數:27,代碼來源:assembla.php


注:本文中的Curl::fetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。