get() public method

Get
public get ( $url, $data = [] ) : mixed
$url
$data
return mixed Returns the value provided by exec.
示例#1
0
 /**
  *
  * @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));
 }
示例#2
0
 /**
  * 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 [];
 }
示例#3
0
 /**
  * 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;
 }
示例#4
0
 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);
 }
示例#5
0
 /**
  * @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);
 }
 /**
  *
  * 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;
 }
示例#7
0
 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);
 }
 /**
  * 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");
 }
示例#9
0
 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;
         }
     }
 }
示例#10
0
 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;
         }
     }
 }
示例#11
0
 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";
     }
 }
示例#12
0
 /**
  * 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);
 }
示例#13
0
 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);
     }
 }
 /**
  * @return string
  */
 protected function getSouceCode()
 {
     if (!$this->curl->response) {
         $this->curl->get('http://proxylist.hidemyass.com/');
     }
     return $this->curl->response;
 }
示例#15
0
 /**
  * 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();
 }
示例#16
0
文件: API.php 项目: oyoy8629/yii-core
 public static function run($method, $params = [])
 {
     self::$defaultParam = ['method' => $method, 'module' => 'API', 'token_auth' => STAT_API_TOKEN, 'format' => 'JSON', 'expanded ' => true, 'idSite' => 1, 'filter_offset' => \yii::$app->request->get('filter_offset', 0), 'filter_limit' => \yii::$app->request->get('filter_limit', 50)];
     $params['formatDate'] = isset($params['formatDate']) ? $params['formatDate'] : null;
     if ($params['formatDate'] !== false) {
         self::formatDate();
     }
     unset($params['formatDate']);
     $params = array_merge(self::$defaultParam, $params);
     $params = array_filter($params);
     $curl = new Curl();
     $curl->setJsonDecoder(function ($response) {
         $json_obj = json_decode($response, true);
         if (!($json_obj === null)) {
             $response = $json_obj;
         }
         return $response;
     });
     $curl->get(STAT_API_URL, $params);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
示例#17
0
 public function deleteBounce($email)
 {
     $param = ['api_user' => $this->apiUser, 'api_key' => $this->apiKey, 'email' => $email];
     $curl = new Curl();
     $response = $curl->get(self::API_BOUNCES_DELETE, $param);
     return $response;
 }
 public function query($dmName, $force = false)
 {
     'http://whois.chinaz.com/?DomainName=teqhost.cn';
     $curl = new Curl();
     $curl->setReferer($this->url);
     $page = $curl->get($this->url, array('DomainName' => $dmName));
     //有时间完善
 }
示例#19
0
 protected function _html()
 {
     $curl = new Curl();
     $curl->setHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
     $curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
     $html = $curl->get($this->url);
     return $html;
 }
示例#20
0
 public function all($year)
 {
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('http://localhost/stripe/index.php/api/v1/earnings/index/' . $year);
     return $curl->response;
 }
 public function view_year($year)
 {
     $curl = new Curl();
     $curl->get(API . "history/year/" . $year);
     return $curl->response;
     // $resp = $curl->response;
     // die("<pre>".print_r($resp, true));
 }
示例#22
0
 public function operator($optrObjectId)
 {
     $curl = new Curl();
     $curl->get(API . "earnings/operator/" . $optrObjectId);
     // die('<pre>'.print_r($curl->response, true));
     $results["operator"] = $curl->response;
     return $results;
 }
示例#23
0
 /**
  * @return string
  */
 public function getMailNo()
 {
     $curl = new Curl();
     $curl->get($this->_getBillnumUrl, ['method' => 'getBillNumBySys', 'xml' => $this->generateBillNumRequestData()]);
     $xml_str = $curl->response;
     $xml = simplexml_load_string(base64_decode($xml_str));
     return (string) $xml->assignIds->assignId->billno;
 }
 public function query($dmName, $force = false)
 {
     //'http://reports.internic.net/cgi/whois?whois_nic=baidu.com&type=domain';
     $curl = new Curl();
     $curl->setReferer($this->refererUrl);
     $Punycode = new Punycode();
     $page = $curl->get($this->url, array('whois_nic' => $Punycode->encode($dmName), 'type' => 'domain'));
     return $this->parse($page);
 }
示例#25
0
 protected function downloadIcon()
 {
     if ($this->data['icon'] != "") {
         $url = "http://us.media.blizzard.com/wow/icons/56/{$this->data['icon']}.jpg";
         $this->curl->get($url);
         return $this->curl->response;
     }
     return false;
 }
示例#26
0
文件: home.php 项目: HLitmus/WebApp
 public function search($query)
 {
     $this->seo(array("title" => "Contact Us", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $curl = new Curl();
     $curl->get('https://maps.googleapis.com/maps/api/place/autocomplete/json', array('input' => $query, 'key' => 'AIzaSyA7Gyp0hkc5frFBy5KLHxU2gu_QPmTnGXQ'));
     $data = $curl->response;
     $view->set("data", $data);
 }
示例#27
0
文件: GitHub.php 项目: arall/cmsdiff
 /**
  * API Call.
  *
  * @param string $path
  *
  * @throws Exception HTTP Error
  *
  * @return string
  */
 private static function apiCall($path)
 {
     $curl = new Curl();
     $curl->get(self::API_URL . $path);
     $curl->close();
     if ($curl->error) {
         throw new Exception('HTTP Error: ' . $curl->error_code . ': ' . $curl->error_message);
     }
     return $curl->response;
 }
 public function appointmentsTimeline()
 {
     $curl = new Curl();
     $curl->setHeader("X-Parse-Application-Id", "yPPe3Uv46pKNnrTc7I6xArFHi8EQ8cdz4Kw3JGkX");
     $curl->setHeader("X-Parse-REST-API-Key", "7PJB1F4g8aFSv5f8e0gSMwi9Ghv2AeAkTW0O50pe");
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('http://52.24.133.167/stripe/index.php/api/v1/history/appointments');
     return $curl->response;
 }
 public function query($dmName, $force = false)
 {
     //'https://whois.cnnic.net.cn/WhoisServlet?queryType=Domain&domain=teqhost.cn';
     $curl = new Curl();
     $curl->setReferer($this->refererUrl);
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $Punycode = new Punycode();
     $page = $curl->get($this->url, array('domain' => $Punycode->encode($dmName), 'queryType' => 'Domain'));
     return $this->parse($page);
 }
示例#30
0
 /**
  * Make the call
  *
  * @author Koen Blokland Visser
  *
  * @param $hash
  * @param $callId
  *
  * @return array
  */
 public function __construct($hash, $callId)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('Accept', 'application/json');
     $curl->setHeader('Hash', $hash);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('https://api.voipgrid.nl/api/clicktodial/' . $callId . '/');
     /** @var array $response */
     $this->response = json_decode($curl->response, true);
 }