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


PHP Requests::get方法代码示例

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


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

示例1: get

 /**
  * post a GET request.
  */
 protected function get($method, $params = array(), $headers = array(), $options = array())
 {
     # construct the query URL.
     $url = self::HOST_API_URL . $method;
     $auth_head = $this->get_auth_header($this->access_key, $this->secret_key);
     if (!$headers) {
         $headers = array();
     }
     if (!$options) {
         $options = array();
     }
     // set timeout
     $options['timeout'] = 10 * 60;
     $headers['Authorization'] = $auth_head;
     // build query url.
     $url = $this->build_http_parameters($url, $params);
     // echo "$url";
     $response = Requests::get($url, $headers, $params, $options);
     // echo $response->body;
     # Handle any HTTP errors.
     if ($response->status_code != 200) {
         throw new ViSearchException("HTTP failure, status code {$response->status_code}");
     }
     # get the response as an object.
     $response_json = json_decode($response->body);
     return $response_json;
 }
开发者ID:bo-git,项目名称:visearch-sdk-php,代码行数:30,代码来源:base_request.php

示例2: getAccount

 /**
  * Get account information
  * 
  * @param Int $id - Account ID
  * @return \Oanda\response\getAccount\AccountFull
  */
 public function getAccount($id)
 {
     $headers = array('Authorization' => 'Bearer ' . $this->getToken());
     $response = \Requests::get($this->getUrl() . '/accounts/' . $id, $headers);
     $this->checkAnswer($response);
     return new \Oanda\response\getAccount\AccountFull(json_decode($response->body));
 }
开发者ID:nikopeikrishvili,项目名称:oanda,代码行数:13,代码来源:Account.php

示例3: applyAccessToken

 /**
  * 获得access_token
  * @return null
  */
 public function applyAccessToken($appid, $secret)
 {
     //        $redis = Redis::connection();
     //        if( ! $redis){
     //            throw new \Exception("redis connect error");
     //        }
     //        $accessToken = $redis->get('dajiayao.device.'.$appid);
     //        if( ! $accessToken){
     //            $url = sprintf(self::GET_TOKEN,$appid,$secret);
     //            $response = \Requests::get($url);
     //            $rtJson = $response->body;
     //            $rtJson = json_decode($rtJson);
     //            if (array_key_exists('access_token', $rtJson)) {
     //                $redis->setex('dajiayao.device.'.$appid,7000,$rtJson->access_token);
     //            }else{
     //                throw new \Exception("weixin get access_token error");
     //            }
     //        }
     //
     //        return $redis->get('dajiayao.device.'.$appid);
     //TODO 后期需要从缓存或者从access_token中央服务器中获取
     $url = sprintf(self::GET_TOKEN, $appid, $secret);
     $response = \Requests::get($url);
     $rtJson = $response->body;
     $rtJson = json_decode($rtJson);
     if (array_key_exists('access_token', $rtJson)) {
         return $rtJson->access_token;
     } else {
         throw new \Exception("weixin get access_token error");
     }
 }
开发者ID:hachi-zzq,项目名称:dajiayao,代码行数:35,代码来源:WeixinClient.php

示例4: zipFile

 /**
  * Get the Zip File from Server & return back the downloaded file location
  */
 public static function zipFile($url, $zipFile)
 {
     if (!extension_loaded('zip')) {
         self::log("Dependency Missing, Please install PHP Zip Extension");
         echo ser("PHP Zip Extension", "I can't find the Zip PHP Extension. Please Install It & Try again");
     }
     self::log("Started Downloading Zip File from {$url} to {$zipFile}");
     $userAgent = 'LobbyBot/0.1 (' . L_SERVER . ')';
     /**
      * Get The Zip From Server
      */
     $hooks = new \Requests_Hooks();
     if (self::$progress != null) {
         $progress = self::$progress;
         $hooks->register('curl.before_send', function ($ch) use($progress) {
             curl_setopt($ch, CURLOPT_NOPROGRESS, false);
             curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $progress);
         });
     }
     try {
         \Requests::get($url, array("User-Agent" => $userAgent), array('filename' => $zipFile, 'hooks' => $hooks, 'timeout' => time()));
     } catch (\Requests_Exception $error) {
         self::log("HTTP Requests Error ({$url}) : {$error}");
         echo ser("Error", "HTTP Requests Error : " . $error);
         return false;
     }
     self::log("Downloaded Zip File from {$url} to {$zipFile}");
     return $zipFile;
 }
开发者ID:LobbyOS,项目名称:server,代码行数:32,代码来源:Update.php

示例5: getDepartures

 /**
  * Gets departures from the given station starting at the given time.
  *
  * @param int $stationID
  * @param Carbon $time
  * @return array
  * @throws ApiException
  */
 public static function getDepartures(int $stationID, Carbon $time, int $maxJourneys = 10)
 {
     // prepare parameters for our request
     $query = ['input' => $stationID, 'boardType' => 'dep', 'time' => $time->format('H:i'), 'date' => $time->format('d.m.y'), 'maxJourneys' => $maxJourneys, 'start' => 'yes'];
     // send it to the bvg mobile site
     $response = \Requests::get(self::getApiEndpoint() . '?' . http_build_query($query));
     if ($response->status_code == 200) {
         // our results array
         $departures = [];
         // prepare document
         $dom = new Dom();
         $dom->load($response->body);
         // get date from API
         $date = $dom->find('#ivu_overview_input');
         $date = trim(substr($date->text, strpos($date->text, ':') + 1));
         $date = Carbon::createFromFormat('d.m.y', $date, 'Europe/Berlin');
         // get table data without the first line (header)
         $rows = $dom->find('.ivu_result_box .ivu_table tbody tr');
         // loop through each departure in the table
         foreach ($rows as $row) {
             // get columns
             $columns = $row->find('td');
             // explode time into two parts
             $time = explode(':', strip_tags($columns[0]));
             // push the departure onto our results array
             $departures[] = ['time' => $date->copy()->hour($time[0])->minute($time[1])->second(0), 'line' => trim(strip_tags($columns[1]->find('a')[0])), 'direction' => trim(strip_tags($columns[2]))];
         }
         // return results
         return $departures;
     } else {
         throw new ApiException('Failed getting station data from BVG API');
     }
 }
开发者ID:mkerix,项目名称:php-bvg,代码行数:41,代码来源:Station.php

示例6: getHelp

 public function getHelp()
 {
     // Get the current version
     $current_version = \Config::get('seat.version');
     // Try determine how far back we are on releases
     $versions_behind = 0;
     try {
         // Check the releases from Github for eve-seat/seat
         $headers = array('Accept' => 'application/json');
         $request = Requests::get('https://api.github.com/repos/eve-seat/seat/releases', $headers);
         if ($request->status_code == 200) {
             $release_data = json_decode($request->body);
             // Try and determine if we are up to date
             if ($release_data[0]->tag_name == 'v' . $current_version) {
             } else {
                 foreach ($release_data as $release) {
                     if ($release->tag_name == 'v' . $current_version) {
                         break;
                     } else {
                         $versions_behind++;
                     }
                 }
             }
         } else {
             $release_data = null;
         }
     } catch (Exception $e) {
         $release_data = null;
     }
     return View::make('help.help')->with('release_data', $release_data)->with('versions_behind', $versions_behind);
 }
开发者ID:boweiliu,项目名称:seat,代码行数:31,代码来源:HelpController.php

示例7: httpGetRequest

 public static function httpGetRequest($url)
 {
     Requests::register_autoloader();
     $headers = array('MP-Public-Key' => MPower_Setup::getPublicKey(), 'MP-Private-Key' => MPower_Setup::getPrivateKey(), 'MP-Master-Key' => MPower_Setup::getMasterKey(), 'MP-Token' => MPower_Setup::getToken(), 'MP-Mode' => MPower_Setup::getMode(), 'User-Agent' => "MPower Checkout API PHP client v1 aka Don Nigalon");
     $request = Requests::get($url, $headers, array('timeout' => 10));
     return json_decode($request->body, true);
 }
开发者ID:votomobile,项目名称:mpower_php,代码行数:7,代码来源:utilities.php

示例8: checkVersion

 /**
  * Check Github for release information
  *
  * @return array
  */
 public function checkVersion()
 {
     // Prepare a return array
     $results = array('release_data' => null, 'versions_behind' => 0);
     // Get the current version
     $current_version = \Config::get('seat.version');
     try {
         // Check the releases from Github for eve-seat/seat
         $headers = array('Accept' => 'application/json');
         $request = \Requests::get('https://api.github.com/repos/eve-seat/seat/releases', $headers);
         if ($request->status_code == 200) {
             $results['release_data'] = json_decode($request->body);
             // Try and determine if we are up to date
             if ($results['release_data'][0]->tag_name == 'v' . $current_version) {
             } else {
                 foreach ($results['release_data'] as $release) {
                     if ($release->tag_name == 'v' . $current_version) {
                         break;
                     } else {
                         $results['versions_behind']++;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         $this->error('[!] Error: Failed to retrieve version information.');
         $this->error('[!] ' . $e->getMessage());
     }
     return $results;
 }
开发者ID:boweiliu,项目名称:seat,代码行数:35,代码来源:SeatUpdate.php

示例9: getFavForums

 public function getFavForums()
 {
     $data = array('tbs' => $this->getTbs());
     $response = Requests::get(self::FAV_URL . "?" . $this->encrypt($data), $this->_headers);
     $response = (array) json_decode($response->body);
     return $response['forum_list'];
 }
开发者ID:friparia,项目名称:tieba,代码行数:7,代码来源:Tieba.class.php

示例10: query_lastfm

 public static function query_lastfm($url)
 {
     debug_event('Recommendation', 'search url : ' . $url, 5);
     $request = Requests::get($url, array(), Core::requests_options());
     $content = $request->body;
     return simplexml_load_string($content);
 }
开发者ID:bl00m,项目名称:ampache,代码行数:7,代码来源:recommendation.class.php

示例11: heva_request

 /**
  * Envoie une requête à HEVA
  */
 public function heva_request($req_uri = "", $params = array())
 {
     $FFVV_Heva_Host = "api.licences.ffvv.stadline.com";
     $head = wsse_header_short($this->config->item('ffvv_id'), $this->config->item('ffvv_pwd'));
     $url = "http://" . $FFVV_Heva_Host . $req_uri;
     return Requests::get($url, array('X-WSSE' => $head), $params);
 }
开发者ID:flub78,项目名称:GVV3,代码行数:10,代码来源:FFVV.php

示例12: get_pasien

 public function get_pasien($no_rm_nasional = '')
 {
     $url = $this->REST_PASIEN_SERVER . '/' . $no_rm_nasional;
     $header = array('Accept' => 'application/json');
     $data = Requests::get($url, $header);
     print_r($data);
 }
开发者ID:arbudt,项目名称:semar_server,代码行数:7,代码来源:reg_pasien.php

示例13: request

 public function request($method, $params = null)
 {
     if (!is_null($params) or !empty($params) && is_array($params)) {
         foreach ($params as $param => $value) {
             $prefix = $value == reset($params) ? '?' : '&';
             $parameters .= sprintf("%s%s=%s", $prefix, $param, urlencode($value));
         }
     } else {
         throw new \Exception('Method request() must have an array argument.');
     }
     $this->query = null;
     if (is_null($this->request_as)) {
         $this->request_as = 'admin';
     }
     # https://tech.yandex.ru/market/partner/doc/dg/concepts/error-codes-docpage/
     $response = \Requests::post("https://pddimp.yandex.ru/api2/{$this->request_as}{$method}{$parameters}", ['Accept' => 'application/json', 'PddToken' => $this->pdd_token, 'Authorization' => $this->oauth_token]);
     if ($response->status_code == 405) {
         $response = \Requests::get("https://pddimp.yandex.ru/api2/{$this->request_as}{$method}{$parameters}", ['Accept' => 'application/json', 'PddToken' => $this->pdd_token, 'Authorization' => $this->oauth_token]);
     }
     switch ($response->status_code) {
         case 200:
             return json_decode($response->body, true);
             break;
         case 405:
             throw new \Exception('Method Not Allowed');
             break;
         default:
             throw new \Exception($response->status_code);
             break;
     }
     $this->request_as = null;
 }
开发者ID:somepony,项目名称:yandexpddapi,代码行数:32,代码来源:API.php

示例14: httpGetRequest

 public static function httpGetRequest($url)
 {
     Requests::register_autoloader();
     $headers = array('PAYDUNYA-PUBLIC-KEY' => Paydunya_Setup::getPublicKey(), 'PAYDUNYA-PRIVATE-KEY' => Paydunya_Setup::getPrivateKey(), 'PAYDUNYA-MASTER-KEY' => Paydunya_Setup::getMasterKey(), 'PAYDUNYA-TOKEN' => Paydunya_Setup::getToken(), 'PAYDUNYA-MODE' => Paydunya_Setup::getMode(), 'User-Agent' => "PAYDUNYA Checkout API PHP client v1 aka Neptune");
     $request = Requests::get($url, $headers, array('timeout' => 10));
     return json_decode($request->body, true);
 }
开发者ID:Katakeyni,项目名称:paydunya-php,代码行数:7,代码来源:utilities.php

示例15: send

 static function send($url, $headers = [], $options = [], $set = ['ret' => 'body', 'post' => ''])
 {
     $default_headers = ['User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36'];
     $default_options = ['follow_redirects' => false, 'timeout' => 30];
     $headers = $headers + $default_headers;
     $options = $options + $default_options;
     //出错的话就访问10次
     for ($i = 1; $i < 10; $i++) {
         \Log::debug("第{$i}次访问" . $url);
         try {
             if (isset($set['post']) && $set['post'] != "") {
                 $html = \Requests::post($url, $headers, $set['post'], $options);
             } else {
                 $html = \Requests::get($url, $headers, $options);
             }
         } catch (\Requests_Exception $e) {
             continue;
             //表示url访问出错了
         }
         if ($html->body != "") {
             break;
         }
         //表示访问正确
     }
     if ($set['ret'] == 'body') {
         return $html->body;
     } else {
         return $html;
     }
 }
开发者ID:wangtongphp,项目名称:weixin-stat,代码行数:30,代码来源:CURL.php


注:本文中的Requests::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。