本文整理汇总了PHP中curl_request函数的典型用法代码示例。如果您正苦于以下问题:PHP curl_request函数的具体用法?PHP curl_request怎么用?PHP curl_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curl_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
private static function execute($search_string)
{
self::$error_msg = false;
if (Controller::$debug) {
var_dump(self::$url . '?' . $search_string);
}
$returned = curl_request(self::$url . '?' . $search_string);
if (!$returned) {
self::$error_msg = 'Invalid Twitter API request';
if (Controller::$debug) {
var_dump(self::$url . '?' . $search_string);
}
return false;
} else {
if (!($result = json_decode($returned))) {
self::$error_msg = 'Invalid JSON returned: ' . $returned;
return false;
}
}
if (array_key_exists('error', $result)) {
self::$error_msg = $result->error;
} else {
return is_object($result) && isset($result->results) ? $result->results : false;
}
if (!empty(self::$error_msg) && Controller::$debug) {
Backend::addError('TwitterSearch: ' . self::$error_msg);
}
return false;
}
示例2: get_itunes_info_native
function get_itunes_info_native($trackid, $store = 'us')
{
if (!$store) {
$store = 'us';
}
$return = curl_request("https://itunes.apple.com/lookup?id={$trackid}&country={$store}&lang=en_us");
return json_decode($return, true);
}
示例3: getView
function getView()
{
$res;
$url = 'http://jw.jxust.cn/default6.aspx';
$result = curl_request($url);
$pattern = '/<input type="hidden" name="__VIEWSTATE" value="(.*?)" \\/>/is';
preg_match_all($pattern, $result, $matches);
$res[0] = $matches[1][0];
return $res;
}
示例4: YahooPlacemakerRequest
function YahooPlacemakerRequest($location, $appid)
{
$encodedLocation = \urlencode($location);
$url = BASE_URL . "v1/document";
$postvars = "documentContent={$encodedLocation}&documentType=text/plain&appid={$appid}";
$return = curl_request($url, $postvars);
$xml = new \SimpleXMLElement($return);
$long = (double) $xml->document->placeDetails->place->centroid->longitude;
$latt = (double) $xml->document->placeDetails->place->centroid->latitude;
$gis = array('lon' => $long, 'lat' => $latt, 'location' => $location);
return $gis;
}
示例5: generate_short_link
function generate_short_link($link)
{
global $API;
$return = curl_request("https://s.appaddict.org/index.php?k=aa_shorten&l=" . urlencode($link));
if (!$return) {
return false;
}
return $return;
/*
require_once('classes/GoogleUrlApi.class.php');
$gapi = new GoogleUrlApi($API->CONFIG['GOOGLE_API_KEY']);
$link = $gapi->shorten($link);
return $link; */
}
示例6: getVcInfo
function getVcInfo($cookiefile)
{
$url = 'http://check.ptlogin2.qq.com/check';
$params = array('appid' => '549000912', 'js_type' => '1', 'js_ver' => '10136', 'login_sig' => '', 'pt_tea' => '1', 'pt_vcode' => '1', 'regmaster' => '', 'u1' => 'http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone');
$params['uin'] = '2716682718';
$params['r'] = '0.' . mt_rand();
$result = curl_request($url . '?' . http_build_query($params), array(), $cookiefile);
$match = array();
$ret = preg_match('#(?<=\\().*(?=\\))#', $result, $match);
$match = explode(',', str_replace('\'', '', $match[0]));
if ($match[0] == 0) {
return array('vcode' => $match[1], 'pt_verifysession_v1' => $match[3]);
return $match[1];
}
return false;
}
示例7: __construct
function __construct($location)
{
parent::__construct('WeatherWidget');
$this->location = $location;
$weather = curl_request('http://www.google.co.za/ig/api', array('weather' => $this->location, 'hl' => 'af', 'C' => 1), array('cache' => 60 * 60));
$weather = simplexml_load_string($weather);
if (!empty($weather->weather->current_conditions)) {
foreach ($weather->weather->current_conditions->children() as $condition => $value) {
$this->current[$condition] = (string) $value['data'];
}
}
if (!empty($weather->weather->forecast_conditions)) {
foreach ($weather->weather->forecast_conditions as $forecast) {
$this->forecast[(string) $forecast->day_of_week['data']] = array('low' => (int) $forecast->low['data'], 'high' => (int) $forecast->high['data'], 'icon' => (string) $forecast->icon['data'], 'condition' => (string) $forecast->condition['data']);
}
}
}
示例8: request
public function request($url, array $parameters = array(), $method = 'GET')
{
$request = $this->get_request($url, $parameters, $method);
$options = array('method' => $method, 'headers' => array('Expect:'), 'callback' => array(__CLASS__, 'handleRequest'));
switch (strtoupper($method)) {
case 'GET':
$returned = curl_request($request, array(), $options);
break;
default:
$returned = curl_request($request, $parameters, $options);
break;
}
if (Controller::$debug >= 2) {
var_dump('Returned', $returned);
}
return $returned;
}
示例9: get_received_by_address
function get_received_by_address($address, $txid, $after_unixtime)
{
if (!preg_match('/[0-9a-zA-Z]{64}/', $txid)) {
return false;
}
$data = json_decode(curl_request('https://blockchain.info/rawtx/' . $txid), true);
if (!$data['out']) {
return false;
}
if ($data['time'] < $after_unixtime) {
return false;
}
foreach ($data['out'] as $out) {
if ($out['addr'] == $address) {
return number_format($out['value'] / 100000000, 8, '.', '');
}
}
return false;
}
示例10: check
public static function check($challenge, $response)
{
self::$error_msg = false;
if (empty($challenge) || empty($response)) {
self::$error_msg = 'Invalid challenge or response';
return false;
}
$params = array('privatekey' => ConfigValue::get('recaptcha.PrivateKey'), 'remoteip' => $_SERVER['REMOTE_ADDR'], 'challenge' => $challenge, 'response' => $response);
$result = curl_request('http://api-verify.recaptcha.net/verify', $params, array('method' => 'post'));
if (!$result) {
self::$error_msg = 'Could not contact reCAPTCHA server';
return false;
}
$result = explode("\n", $result);
if ($result[0] != 'true') {
self::$error_msg = $result[1];
return false;
}
return true;
}
示例11: action_update
/**
* @todo We need to find a way to tag files with it's revision
* @todo update overrides TableCtl::update
*/
function action_update()
{
$location = Backend::getConfig('application.file_provider.location', false);
if (!$location) {
Backend::addError('No File Provider Location');
return false;
}
$files = Component::fromFolder();
foreach ($files as $file) {
$rev_id = self::getRevisionFromFile($file);
$result = curl_request($location, array('q' => 'backend_file/read/' . urlencode($file), 'mode' => 'json'));
if ($result && ($result = @json_decode($result, true))) {
$info = $result['result'];
if ($info['version'] != $rev_id) {
//File is out old
}
} else {
Backend::addError('Could not check status for ' . $file);
}
}
}
示例12: get_itunes_info2
function get_itunes_info2($trackid, $type = 'app', $store = 'us', $no_recursion = false)
{
// proxy https://itunes.apple.com
if (!$store) {
$store = 'us';
}
if (!$type) {
$type = 'app';
}
$proxies = array('http://127.0.0.1:81', 'http://188.165.24.108', 'http://94.23.169.52:81');
//if ($_COOKIE['test']) var_dump("{$store}/{$type}/id{$trackid}/?l=en");
$data = curl_request("https://itunes.apple.com/{$store}/{$type}/id{$trackid}/?l=en", 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)');
//try_itunes_proxy("{$store}/{$type}/id{$trackid}/?l=en", $proxies);
//var_Dump($data);
$app['type'] = $type;
$app['trackid'] = $trackid;
$app['store'] = $store;
if ($type == 'book') {
preg_match("#its.serverData=(.*?)</script>#si", $data, $matches);
$data = json_decode($matches[1], true);
$data = $data['pageData']['productData'];
$data['_reviews_']['current'] = json_decode(curl_request($data['reviews-url'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
} elseif ($type == 'app') {
$data = json_decode($data, true);
$data['_reviews']['current'] = json_decode(curl_request($data['reviewsUrlsData']['currentVersionUrl'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
$data['_reviews']['all'] = json_decode(curl_request($data['reviewsUrlsData']['allVersionsUrl'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
if ($data['customersAlsoBought']['childrenIds']) {
foreach ($data['customersAlsoBought']['childrenIds'] as $cid) {
if (!$no_recursion) {
$data['_alsobought'][$cid] = get_itunes_info2($cid, $type, $store);
}
}
}
}
if (!$data) {
return false;
}
return $data;
}
示例13: process_object
function process_object($data, $tag, $propery, $value, $class = false)
{
$headers = '';
$url = html_entity_decode($data['url']);
$page = curl_request($url, $headers);
$dom = new simple_html_dom();
$dom->load($page);
$iframe = '';
if (!$class) {
$iframe = $dom->find("{$tag}[{$propery}={$value}] object");
} else {
$iframe = $dom->find("{$tag}.{$value} object");
}
if (!isset($iframe[0]->outertext)) {
return null;
}
preg_match("/(<object.*? <\\/object>)/", $iframe[0]->outertext, $matches);
$iframe = $matches[0];
$patterns = [0 => '/width=["|\'].*?["|\']/', 1 => '/height=["|\'].*?["|\']/'];
$replacements = [0 => 'width="640"', 1 => 'height="390"'];
$frame = preg_replace($patterns, $replacements, $iframe);
$result = ['data' => $data, 'embed' => $frame];
return $result;
}
示例14: getCNOrderDetails
function getCNOrderDetails($source_data)
{
$data = array();
$headers = build_http_headers('order', 'getOrderDetails');
$source_data = array('CN100000204', 'CN100000398', 'CN100000407', 'CN100000411', 'CN100000420', 'CN100000422');
$pagination_data = array('PerPage' => 2, 'CurrPage' => 1);
while (true) {
$data['pagination'] = $pagination_data;
$data['data'] = $source_data;
$return_data = curl_request($headers, array('erp_data' => json_encode($data)));
//print_r($return_data);die;
$return_data = json_decode($return_data, true);
//echo $return_data->HasMoreOrders;
print_r($return_data);
$return[] = $return_data;
$HasMoreOrders = $return_data['HasMoreOrders'];
$CurrPage = $return_data['PaginationResult']['CurrPage'];
if ($HasMoreOrders == false || $HasMoreOrders == 0) {
break;
}
$pagination_data['CurrPage'] = $CurrPage + 1;
}
return $return;
}
示例15: weather
/**
* 获取今天天气,分别使用了Taobao的IP查询接口、百度的LBS的简易天气接口
* @return array|mixed
* @author Mr.Cong <i@cong5.net>
*/
public function weather()
{
//新从缓存去检查,如果有则取缓存的数据
$weatherCached = S('weather');
if ($weatherCached != false) {
return $weatherCached;
}
//获取客户端IP
$client_ip = get_client_ip();
//如果是本地,且是DEBUG是TRUE,则把IP替换一下,让其正常显示数据
if ('127.0.0.1' === $client_ip) {
$client_ip = '116.10.197.226';
}
//根据IP来获取所在城市
$ip_api = sprintf(C('IPADDR_API'), $client_ip);
$ipData = curl_request($ip_api);
$enIpData = json_decode($ipData, true);
//根据城市来获取天气
$city = $enIpData['data']['city'];
$weather_api = C('WEATHER_API') . $city;
$weatherData = curl_request($weather_api);
$data = json_decode($weatherData, true);
$SourceWeather = $data['results'][0]['weather_data'][0];
//筛选和重组数据
$weather = array('date' => $SourceWeather['date'], 'dayPictureUrl' => $SourceWeather['dayPictureUrl'], 'nightPictureUrl' => $SourceWeather['nightPictureUrl'], 'weather' => $SourceWeather['weather'], 'wind' => $SourceWeather['wind'], 'temperature' => $SourceWeather['temperature']);
S('weather', $weather, $this->cachedOptionsWithRedis);
$this->response($weather, 'json');
}