当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP::setURL方法代码示例

本文整理汇总了PHP中HTTP::setURL方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::setURL方法的具体用法?PHP HTTP::setURL怎么用?PHP HTTP::setURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP的用法示例。


在下文中一共展示了HTTP::setURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pushoverRecipient

 /**
  * Pushover Recipient
  *
  * Validates Pushover UID and GIDs
  *
  * @param string $key
  * @param string $app
  * @return bool
  */
 public static function pushoverRecipient($key, $app)
 {
     $pattern = '/^[ug][A-Za-z0-9]{29}$/';
     if (preg_match($pattern, $key)) {
         $http = new HTTP();
         $http->setURL('https://api.pushover.net/1/users/validate.json');
         $http->setSecure(true);
         $http->setPostContent(array('token' => $app, 'user' => $key));
         $r = $http->run();
         if ($r['code'] === 200) {
             if (json_decode($r['body'], true)['status'] === 1) {
                 return true;
             }
         } elseif ($r['code'] !== 200) {
             throw new Exception("Failed to contact Pushover API to verify UID/GID (Status code !== 200).");
         }
     }
     return false;
 }
开发者ID:ZacharyDuBois,项目名称:Research-Botnet,代码行数:28,代码来源:Validation.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::setURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。