只是要快了,我用我的xhttp class这是一个卷曲的包装,我觉得代码非常容易。
<?php
header('content-type: text/plain');
// Set account login info
$data['post'] = array(
'accountType' => 'HOSTED_OR_GOOGLE', // indicates a Google account
'Email' => '', // full email address
'Passwd' => '',
'service' => 'trendspro', // Name of the Google service
'source' => 'codecri.me-example-1.0' // Application's name, e.g. companyName-applicationName-versionID
);
$response = xhttp::fetch('https://www.google.com/accounts/ClientLogin', $data);
// Test if unsuccessful
if(!$response['successful']) {
echo 'response: '; print_r($response);
die();
}
// Extract SID
preg_match('/SID=(.+)/', $response['body'], $matches);
$sid = $matches[1];
// Erase POST variables used on the previous xhttp call
$data = array();
// Set the SID in cookies
$data['cookies'] = array(
'SID' => $sid
);
$response = xhttp::fetch('http://www.google.com/insights/search/overviewReport?q=lingerie&geo=ID&cmpt=q&content=1&export=1', $data);
// CSV data in the response body
echo $response['body'];
?>
结果是:http://codecri.me/apps/test/test.google.trends.php 但我不知道,如果结果是你在找什么。
是否谷歌甚至有趋势/搜索见解的API?据我所见,API中唯一可用的google洞察就是youtube的见解。如果有这样的API,请提供链接? – Niklas 2011-06-05 16:47:52
没有..但有一个可下载的CSV。而且它可以在我们登录时下载(请参阅google auth文章)。多数民众赞成的问题,我不知道如何使用卷曲发送像“你好,这是我即时登录让我下载.CSV文件”。 – 2011-06-05 17:53:40