我尝试使用google-api-php-client SDK以及google plus api服务。文件不是很清楚。我搜索活动吗?我需要获得oAuth令牌来做我想要的吗?
更新:现在使用
$params = array(
'orderBy' => 'best',
'maxResults' => '20',
'query' => 'Google+ API'
);
$results = $plus->activities->search($params);
返回
Array
(
[kind] => plus#activityFeed
[etag] => "5NTCbsXue5u92XtxuV0QeM_x9B4/58mHUy-IErItGIABIAhYhhUjJ-M"
[selfLink] => https://www.googleapis.com/plus/v1/activities?query&maxResults=10
[title] => Plus Search
[updated] => 2012-09-27T14:03:35.132Z
[id] => tag:google.com,2010:es-search-feed:z80ghJXVZe9m59_5-Ydk2g
[items] => Array
(
)
)
答案 0 :(得分:1)
我遇到了同样的问题,这就是我如何做到的:
$query = "some query";
$params = array(
'orderBy' => 'best',
'maxResults' => '20',
);
$results = $plus->activities->search($query, $params);
foreach($results['items'] as $result) {
print "Result: {$result['object']['content']}\n";
}
在示例查询中,即使面团也不是参数的一部分。它应该以分开的值发送,正如您在加服务Link的搜索方法的实现中所看到的那样
希望这会对你有所帮助。
答案 1 :(得分:0)
您不需要OAuth令牌来搜索活动。您只需在Google API控制台中注册开发人员密钥。
样品:
$params = array(
'orderBy' => 'best',
'maxResults' => '20',
'query' => 'Google+ API'
);
$results = $plus->activities->search($params);
foreach($results['items'] as $result) {
print "Result: {$result['object']['content']}\n";
}