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


PHP HTTP::exec方法代碼示例

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


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

示例1: getIP

/**
 * 得到當前用戶的公網IP,目前是通過ip138來實現的.
 * */
function getIP()
{
    $ht = new HTTP("http://www.ip138.com/ip2city.asp", "GET");
    #$ht=new HTTP("http://www.dnspod.com/About/IP","GET");
    $ret = $ht->exec();
    $patt = "/\\[([0-9\\.]*)\\]/";
    preg_match_all($patt, $ret, $out);
    return array_pop(array_pop($out));
}
開發者ID:962464,項目名稱:phppod,代碼行數:12,代碼來源:phppod.php

示例2: getMatches

 /**
  * Get Matches and Alliances
  *
  * Returns an array of matches and the alliances for each match at an event.
  *
  * @param string $eventKey
  * @return array|false
  * @throws Exception
  */
 public function getMatches($eventKey)
 {
     if (!is_string($eventKey)) {
         throw new Exception("eventKey is not string: " . $eventKey);
     }
     $request = new HTTP($this->TConfig);
     $request->setURL(static::uri . '/event/' . $eventKey . '/matches');
     $request->setHeaders($this->setAPIHeaders());
     $out = $request->exec();
     if ($out['code'] !== 200) {
         throw new Exception("Event key matches returned non-200 response code: " . $out['code']);
     }
     $body = json_decode($out['body'], true);
     if (!is_array($body)) {
         //throw new Exception("getMatches(...) request body was not array when attempted to be decoded.");
         return false;
     }
     if (count($body) > 0) {
         $matches = array();
         foreach ($body as $match => $data) {
             $matches[$match] = array('matchNumber' => $data['match_number'], 'setNumber' => $data['set_number'], 'red' => $data['alliances']['red']['teams'], 'blue' => $data['alliances']['blue']['teams']);
         }
         unset($body);
         unset($out);
         unset($request);
         return $matches;
     }
     return false;
 }
開發者ID:cougarTech2228,項目名稱:Alliance-Scraper,代碼行數:38,代碼來源:BlueAlliance.php


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