I'm working on Bright Local API ( https://tools.brightlocal.com/ ) to get reviews of a business from Yelp ,Google+ etc. I got some code of this API from GitHub with some examples.So I just register a free account in Bright Local and try those examples to get Reviews.
Below code is used to fetch the reviews of some business.After running this code i got a job id.But I dont know how to get reviews using this Job 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;
}
}
Anybody knows how to get reviews using this API ?
Thanks in advance.
It looks like you're missing the final step which is to poll for results. Our system works by adding jobs to a queue and then processing those jobs in parallel. Having created a batch, added jobs to that batch and committed it you then need to set up a loop, or come back and check for results periodically, until you see that the batch is marked as "Finished" and all jobs have returned data.
To do this call:
$results = $batchApi->get_results($batchId); // repeat this call until complete
$results will contain "status" which will be marked as "Finished" once all jobs have finished processing as well as the actual results associated with each job.