天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

用PHP獲取Google AJAX Search API 數據的代碼

http://code.google.com/apis/ajaxsearch/documentation/#fonje
復制代碼 代碼如下:
// This example request includes an optional API key which you will need to
// remove or replace with your own key.
// Read more about why it's useful to have an API key.
// The request also includes the userip parameter which provides the end
// user's IP address. Doing so will help distinguish this legitimate
// server-side traffic from traffic which doesn't come from an end-user.
$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
. "q=Paris%20Hilton&key=INSERT-YOUR-KEY&userip=USERS-IP-ADDRESS";

// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, /* Enter the URL of your site here */);
$body = curl_exec($ch);
curl_close($ch);

// now, process the JSON string
$json = json_decode($body);
// now have some fun with the results...

API KEY 申請地址:
http://code.google.com/apis/ajaxsearch/signup.html

由此,我們可以寫個函數像這樣
復制代碼 代碼如下:
function google_search_api($args, $referer = 'http://www.jb51.NET/', $endpoint = 'web'){
$url = "http://ajax.googleapis.com/ajax/services/search/".$endpoint;
if ( !array_key_exists('v', $args) )
$args['v'] = '1.0';
$url .= '?'.http_build_query($args, '', '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
$body = curl_exec($ch);
curl_close($ch);
return json_decode($body);
}

// 使用示例
$rez = google_search_api(array(
'q' => '21andy.com', // 查詢內容
'key' => '你申請到的API KEY',
'userip' => '你的IP地址',
));
header('Content-type: text/html; charset=utf-8;');
echo '<xmp>';
print_r($rez);
echo '</xmp>';

php技術用PHP獲取Google AJAX Search API 數據的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 被男按摩师添的好爽在线直播 | 精精国产www视频在线观看免费 | 一个人看的www视频动漫版 | 不戴套挺进人妻怀孕 | 韩国电影real在线观看完整版 | 97免费人妻在线观看 | 这里只有精品在线视频 | BL文高H强交| 国产一区二区三区四区五在线观看 | 日产亚洲一区二区三区 | 久久婷婷五月免费综合色啪 | 广东95后小情侣酒店自拍流出 | 久久精品视频在线看15 | 国产高清亚洲日韩字幕一区 | 姑娘视频日本在线播放 | 久久这里只精品热在线18 | 男子扒开美女尿口做羞羞的事 | 国产精品一区二区AV白丝在线 | 国产毛A片久久久久久无码 国产毛A片啊久久久久久A | 果冻传媒2021一二三在线观看 | 伊人网中文字幕 | 新金梅瓶玉蒲团性奴3 | 久久夜色精品国产亚州AV卜 | 双性被疯狂灌满精NP | 狼群影院视频在线观看WWW | 先锋资源久久 | 久久中文字幕人妻AV熟女 | mm625亚洲人成电影网 | 漂亮的保姆3集电影免费观看中文 | 三级叫床震大尺度视频 | 97视频在线免费 | 久久久久久久国产精品视频 | 99re6久久在热线视频 | 护士被老头边摸边吃奶的视频 | 乱奷XXXXXHD | 在线观看亚洲免费视频 | 思思99精品国产自在现线 | 日本激情网址 | 久久综合一个色综合网 | 暖暖 视频 免费 高清 在线观看 | 成人在线观看播放 |