<?php

require '../Auth.php';
require '../../vendor/autoload.php';
use BrightLocal\Api;
use BrightLocal\Batches\V4 as BatchApi;
$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;
    }
}
Пример #2
0
<?php

require '../Auth.php';
require '../../vendor/autoload.php';
use BrightLocal\Api;
use BrightLocal\Batches\V4 as BatchApi;
$directories = array('google', 'citysearch', 'dexknows', 'kudzu', 'manta');
// setup API wrappers
$api = new Api(API_KEY, API_SECRET, API_ENDPOINT);
$batchApi = new BatchApi($api);
// Step 1: Create a new batch
$result = $batchApi->create();
if ($result['success']) {
    $batchId = $result['batch-id'];
    printf('Created batch ID %d%s', $batchId, PHP_EOL);
    // Step 2: Add directory jobs to batch
    foreach ($directories as $directory) {
        $result = $api->call('/v4/ld/fetch-profile-url', array('batch-id' => $batchId, 'local-directory' => $directory, 'business-names' => 'Eleven Madison Park', 'country' => 'USA', 'city' => 'New York', 'postcode' => '10010'));
        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)
    $result = $batchApi->commit($batchId);
    if ($result['success']) {
        echo 'Committed batch successfully.' . PHP_EOL;
    }
}
Пример #3
0
 /**
  * @param int $batchId
  * @return bool
  */
 public function delete($batchId)
 {
     $results = $this->api->call('/v4/batch', array('batch-id' => $batchId), Api::HTTP_METHOD_DELETE);
     return $results['success'];
 }
Пример #4
0
 /**
  * @param string $batchId
  * @return bool|mixed
  */
 public function get_results($batchId)
 {
     return $this->api->call('/v1/get-batch-results', array('batch-id' => $batchId));
 }