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


PHP Curl::start方法代碼示例

本文整理匯總了PHP中Curl::start方法的典型用法代碼示例。如果您正苦於以下問題:PHP Curl::start方法的具體用法?PHP Curl::start怎麽用?PHP Curl::start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Curl的用法示例。


在下文中一共展示了Curl::start方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: start

 public function start()
 {
     $content = parent::start();
     // false means cURL failed
     if ($content === false) {
         throw new Exception('cURL error: ' . $this->getErrorMessage());
     }
     // anything else than status code 2xx is most likely bad
     $iHttpCode = $this->getHttpCode();
     if ($iHttpCode < 200 || $iHttpCode > 299) {
         throw new Exception('Server error: ' . HttpHeader::getHttpCodeString($iHttpCode));
     }
     return $content;
 }
開發者ID:fedyamaslov1987,項目名稱:steamprofile,代碼行數:14,代碼來源:HttpLoader.class.php

示例2: start

 public function start()
 {
     $content = parent::start();
     // false means cURL failed
     if ($content === false) {
         throw new Exception('cURL error: ' . $this->getErrorMessage());
     }
     // anything else than status code 2xx is most likely bad
     $iHttpCode = $this->getHTTPCode();
     if ($iHttpCode < 200 || $iHttpCode > 299) {
         throw new Exception('Server error: ' . HTTPHeader::getHTTPCodeString($iHttpCode));
     }
     // check if the we actually downloaded anything
     if (strlen($content) == 0) {
         throw new Exception('Empty profile data');
     }
     // trim extra profile data (groups, friends, most played games)
     if ($this->bTrimExtra) {
         $sEndToken = '</summary>';
         $iEndPos = strpos($content, $sEndToken);
         if ($iEndPos !== false) {
             $content = substr($content, 0, $iEndPos + strlen($sEndToken));
             $content .= "\n</profile>";
         }
     }
     // remove certain control characters that are misleadingly send by the API,
     // which are invalid in XML 1.0
     if ($this->bFilterCtlChars) {
         $aCtlChr = array();
         for ($i = 0; $i < 32; $i++) {
             // tab, lf and cr are allowed
             if ($i == 9 || $i == 10 || $i == 13) {
                 continue;
             }
             $aCtlChr[] = chr($i);
         }
         $content = str_replace($aCtlChr, '', $content);
     }
     return $content;
 }
開發者ID:vulcandth,項目名稱:steamprofile,代碼行數:40,代碼來源:SteamProfileLoader.php


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