本文整理汇总了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));
}
示例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 [];
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
}
}
示例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;
}
}
}
示例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";
}
}
示例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);
}
示例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);
}
}
示例14: getSouceCode
/**
* @return string
*/
protected function getSouceCode()
{
if (!$this->curl->response) {
$this->curl->get('http://proxylist.hidemyass.com/');
}
return $this->curl->response;
}
示例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();
}