【发布时间】:2015-02-25 09:15:42
【问题描述】:
我正在开发 Bright Local API (https://tools.brightlocal.com/),以获取来自 Yelp、Google+ 等的商家评论。 我从 GitHub 获得了这个 API 的一些代码和一些示例。所以我只需在 Bright Local 中注册一个免费帐户并尝试这些示例以获得评论。
以下代码用于获取某些业务的评论。运行此代码后,我得到了一个工作 ID。但我不知道如何使用此工作 ID 获取评论。
$profileUrls = array(
'https://plus.google.com/114222978585544488148/about?hl=en',
'https://plus.google.com/117313296997732479889/about?hl=en',
'https://plus.google.com/111550668382222753542/about?hl=en'
);
// setup API wrappers
$api = new Api(API_KEY, API_SECRET, API_ENDPOINT);
$batchApi = new BatchApi($api);
// Step 1: Create a new batch
$batchId = $batchApi->create();
if ($batchId) {
printf('Created batch ID %d%s', $batchId, PHP_EOL);
// Step 2: Add review lookup jobs to batch
foreach ($profileUrls as $profileUrl) {
$result = $api->call('/v4/ld/fetch-reviews', array(
'batch-id' => $batchId,
'profile-url' => $profileUrl,
'country' => 'USA'
));
if ($result['success']) {
printf('Added job with ID %d%s', $result['job-id'], PHP_EOL);
}
}
// Step 3: Commit batch (to signal all jobs added, processing starts)
if ($batchApi->commit($batchId)) {
echo 'Committed batch successfully.'.PHP_EOL;
}
}
有人知道如何使用此 API 获得评论吗?
提前致谢。
【问题讨论】:
标签: php google-plus review yelp