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


PHP Curl::get方法代码示例

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


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

示例1: sendSparqlUpdateQuery

 /**
  *
  * @param string $query
  * @return
  * @throw
  */
 public function sendSparqlUpdateQuery($query)
 {
     // TODO extend Accept headers to further formats
     $this->client->setHeader("Accept", "application/sparql-results+json");
     $this->client->setHeader("Content-Type", "application/sparql-update");
     return $this->client->get($this->url, array("query" => $query));
 }
开发者ID:guitarmarx,项目名称:Saft,代码行数:13,代码来源:Client.php

示例2: getLocation

 /**
  * Returns a location for the given IP
  *
  * @param  string   $ip
  *
  * @return string[] Location information
  */
 public function getLocation($ip)
 {
     $this->curl->get('http://ip-api.com/json/' . $ip);
     if (!$this->curl->error) {
         return json_decode($this->curl->response, true);
     }
     return [];
 }
开发者ID:leroy-merlin-br,项目名称:geo,代码行数:15,代码来源:IpLocator.php

示例3: request

 /**
  * Execute a request against the url.
  *
  * @param string $url
  * @param array  $params
  *
  * @return mixed
  */
 public function request($url, array $params = [])
 {
     $this->curl->get($url, $params);
     $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $response = $this->curl->response;
     $this->curl->close();
     return $response;
 }
开发者ID:kamaroly,项目名称:shift,代码行数:16,代码来源:Recaptcha.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $curl = new Curl();
     $curl->get('http://www.pornhub.com/rss');
     $curl->get('http://1000-downers.tumblr.com/rss');
     $output->writeln('Pornhub feed downloaded');
     $name = $input->getArgument('name');
     $text = 'Hello ' . $name;
     $output->writeln($text);
 }
开发者ID:Northys,项目名称:rss-crawler,代码行数:10,代码来源:Crawl.php

示例5: getSubAccount

 /**
  * @param string $apiKey
  * @param string $apiSecret
  * @param int    $subAccountId
  *
  * @return AccountResponse
  */
 public static function getSubAccount($apiKey, $apiSecret, $subAccountId)
 {
     $apiEndpoint = sprintf('%s/subaccounts/%s', self::API_URL, $subAccountId);
     $curl = new Curl();
     $curl->get($apiEndpoint, json_encode(['api_key' => $apiKey, 'api_secret' => $apiSecret]));
     return self::parseResponse($curl);
 }
开发者ID:mikeymike,项目名称:kraken,代码行数:14,代码来源:Account.php

示例6: callWebservice

 /**
  *
  * https://developer.priceminister.com/blog/fr/documentation/product-data/product-listing-secure
  *
  * @return mixed
  */
 public function callWebservice()
 {
     $urlToCall = 'https://ws.priceminister.com/listing_ssl_ws';
     $curl = new Curl();
     $curl->get($urlToCall, ['action' => 'listing', 'login' => $this->credentials['login'], 'pwd' => $this->credentials['password'], 'version' => '2015-07-05', 'scope' => 'PRICING', 'kw' => $this->searchTerm, 'refs' => '', 'nbproductsperpage' => 20, 'pagenumber' => 1]);
     return $curl->response;
 }
开发者ID:pgrimaud,项目名称:marketplaces-search,代码行数:13,代码来源:PriceministerMarketplace.php

示例7: mpimHistory

 protected function mpimHistory(Bot $bot, $mpim_id)
 {
     $mpim = $bot->rooms[$mpim_id];
     $token = $bot->bot_token;
     $response = $this->curl->get('https://slack.com/api/im.history', ['token' => $token, 'channel' => $mpim_id, 'oldest' => $mpim->latest, 'inclusive' => 0]);
     $this->responseHistory($bot, $mpim_id, $token, $response);
 }
开发者ID:Mailclark,项目名称:bot2hook,代码行数:7,代码来源:Server.php

示例8: actionCommodities

 /**
  * Imports commodity information from EDDB
  */
 public function actionCommodities()
 {
     $eddbApi = Yii::$app->params['eddb']['archive'] . 'commodities.json';
     $curl = new Curl();
     $curl->get($eddbApi);
     if ($curl->error) {
         throw new \yii\base\Exception('Error: ' . $curl->errorCode . ': ' . $curl->errorMessage);
     }
     // Iterate through all the categories via the curl response and insert them into the database
     foreach ($curl->response as $k => $obj) {
         $this->stdOut("Importing: ");
         $this->stdOut("{$obj->name}\r", Console::BOLD);
         $category = CommodityCategory::find()->where(['id' => $obj->category_id])->one();
         if ($category === NULL) {
             $this->stdOut('Importing new category: ' . $obj->category->name . "\n");
             $category = new CommodityCategory();
             $category->id = $obj->category_id;
         }
         $category->name = $obj->category->name;
         $category->save();
         // Import the commodity
         $commodity = Commodity::find()->where(['id' => $obj->id])->one();
         if ($commodity === NULL) {
             $this->stdOut('Importing new commodity: ' . $obj->name . "\n");
             $commodity = new Commodity();
             $commodity->id = $obj->id;
             $commodity->name = $obj->name;
         }
         $commodity->average_price = $obj->average_price;
         $commodity->category_id = $obj->category_id;
         $commodity->save();
     }
     $this->stdOut("\n\r");
 }
开发者ID:charlesportwoodii,项目名称:galnet-api,代码行数:37,代码来源:ImportController.php

示例9: getWeChatIp

 public static function getWeChatIp()
 {
     $api = 'https://api.weixin.qq.com/cgi-bin/getcallbackip';
     $url_query = '?access_token=' . self::$token->getToken();
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);
     $curl->get($api . $url_query);
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         if (isset($curl->response->errcode)) {
             switch ($curl->response->errcode) {
                 case '40002':
                     die($curl->response->errmsg);
                     break;
                 case '40013':
                     die($curl->response->errmsg);
                     break;
                 case '40125':
                     die($curl->response->errmsg);
                     break;
                 default:
                     die('未知错误');
                     break;
             }
         } else {
             return $curl->response;
         }
     }
 }
开发者ID:shsrain,项目名称:ShsrainWeChat,代码行数:31,代码来源:WeChat.php

示例10: getAccessToken

 protected function getAccessToken()
 {
     $url_query = '?grant_type=' . $this->grant_type;
     $url_query .= '&appid=' . $this->appid;
     $url_query .= '&secret=' . $this->secret;
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);
     $curl->get($this->token_api . $url_query);
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         if (isset($curl->response->errcode)) {
             switch ($curl->response->errcode) {
                 case '40002':
                     die($curl->response->errmsg);
                     break;
                 case '40013':
                     die($curl->response->errmsg);
                     break;
                 case '40125':
                     die($curl->response->errmsg);
                     break;
                 default:
                     throw new TokenExpiredException("未知错误");
                     break;
             }
         } else {
             return $curl->response;
         }
     }
 }
开发者ID:shsrain,项目名称:ShsrainWeChat,代码行数:32,代码来源:Token.php

示例11: api

 function api()
 {
     $apiKey = Input::get('apiKey');
     if (!$apiKey) {
         \App::abort(500);
     }
     $sysKey = config('settings.apiKey');
     if ($sysKey !== $apiKey) {
         \App::abort(500);
     }
     $base = Input::get('image');
     $binary = base64_decode($base);
     $fname = rand(0, 100) . ".jpg";
     header('Content-Type: bitmap; charset=utf-8');
     $file = fopen(base_path() . "/uploads/" . $fname, 'wb');
     fwrite($file, $binary);
     fclose($file);
     $furl = asset('/uploads/' . $fname);
     $curl = new Curl();
     $key = config('settings.idol.key');
     $url = config('settings.idol.orc_url');
     $response = $curl->get($url, array('apikey' => $key, 'url' => $furl));
     if ($response && isset($response->text_block)) {
         return $response->text_block[0]->text;
     } else {
         return "error";
     }
 }
开发者ID:kunalvarma05,项目名称:eventup,代码行数:28,代码来源:HomeController.php

示例12: getWithParams

 /**
  * HTTP GET wrapper for Curl.
  * For requests with additional query parameters.
  *
  * @param string $url URL to GET request to.
  * @return mixed Response data.
  */
 public function getWithParams($url)
 {
     $curl = new Curl();
     $curl->get($this->endpoint . $url . '&api_token=' . $this->token);
     $curl->close();
     return json_decode($curl->response);
 }
开发者ID:maciekmp,项目名称:pipedrive-php-api,代码行数:14,代码来源:HTTP.php

示例13: getTrackingInformation

 private function getTrackingInformation()
 {
     $curl = new Curl();
     $curl->get(self::BPOST_API_ENDPOINT . 'items?itemIdentifier=' . $this->getItemNumber());
     if ($curl->error) {
         throw new Exception('CURL error while fetching tracking information: ' . $curl->errorCode . ': ' . $curl->errorMessage);
     }
     // Curl library already decoded the JSON (cool!)
     $response = $curl->response[0];
     // Decode sender
     $rawSender = $response->sender;
     $this->sender = new SenderReceiver($rawSender->countryCode, $rawSender->municipality, $rawSender->postcode);
     // Decode receiver
     $rawReceiver = $response->receiver;
     $this->receiver = new SenderReceiver($rawReceiver->countryCode, $rawReceiver->municipality, $rawReceiver->postcode, $rawReceiver->name);
     // Some other stuff
     $this->weight = (int) $response->weightInGrams;
     $this->customerReference = $response->customerReference;
     $this->requestedDeliveryMethod = $response->requestedDeliveryMethod;
     // Decode events
     $rawEvents = $response->events;
     foreach ($rawEvents as $rawEvent) {
         $lang = self::LANGUAGE;
         $eventDescription = $this->translateKey($rawEvent->key);
         $statusUpdate = new StatusUpdate($rawEvent->date, $rawEvent->time, $eventDescription, $rawEvent->location->{$lang});
         array_push($this->statusUpdates, $statusUpdate);
     }
 }
开发者ID:savjee,项目名称:bpost-track,代码行数:28,代码来源:BpostPackage.php

示例14: getSouceCode

 /**
  * @return string
  */
 protected function getSouceCode()
 {
     if (!$this->curl->response) {
         $this->curl->get('http://proxylist.hidemyass.com/');
     }
     return $this->curl->response;
 }
开发者ID:nguyenvanduocit,项目名称:hidemyass-scraper,代码行数:10,代码来源:HideMyAssAPI.php

示例15: init

 /**
  * Init CLDR data and download default language
  */
 public function init()
 {
     if (!is_file($file = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'core.zip')) {
         $fp = fopen($file, "w");
         $curl = new Curl();
         $curl->setopt(CURLOPT_FILE, $fp);
         $curl->setopt(CURLOPT_FOLLOWLOCATION, true);
         $curl->setopt(CURLOPT_HEADER, false);
         $curl->get(self::ZIP_CORE_URL);
         if ($curl->error) {
             throw new \Exception("Failed to download '" . self::ZIP_CORE_URL . "'.");
         }
         fclose($fp);
     }
     //extract ONLY supplemental json files
     $archive = new \ZipArchive();
     if ($archive->open($file) === true) {
         for ($i = 0; $i < $archive->numFiles; $i++) {
             $filename = $archive->getNameIndex($i);
             if (preg_match('%^supplemental\\/(.*).json$%', $filename)) {
                 if (!is_dir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename))) {
                     mkdir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename), 0777, true);
                 }
                 if (!file_exists($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename)) {
                     copy("zip://" . $file . "#" . $filename, $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename);
                     $this->newDatasFile[] = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename;
                 }
             }
         }
         $archive->close();
     } else {
         throw new \Exception("Failed to unzip '" . $file . "'.");
     }
     $this->generateSupplementalDatas();
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:38,代码来源:Update.php


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