Request Examples
This page provides practical examples of how to use the ReviewData Lite API endpoints in different programming languages. These examples use the same default values as the interactive playground for consistency.
Base URL
All API requests are made to: https://data.reviewdata.ai
Request Reviews Examples
- JavaScript (Node.js)
- Python
- PHP
const axios = require('axios');
const requestReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE', // Replace with your API key
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: [
'restaurant',
'pizza',
'italian',
'casual'
],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Classic, long-running fast-food chain known for its burgers & fries.'
},
publishers: {
'maps.google.com': {
profile_key: 'https://www.google.com/maps/place/McDonald\'s/@40.7094789,-74.0126167,886m/data=!3m2!1e3!5s0x89c2592f4977ef97:0xf78d57398ac93494!4m7!3m6!1s0x89c25a177d4bf5db:0x84e51f23e8c0a75c!8m2!3d40.7094789!4d-74.0100364!10e1!16s%2Fg%2F1thtf190!5m1!1e1?entry=ttu&g_ep=EgoyMDI1MDYyMi4wIKXMDSoASAFQAw%3D%3D',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}` // Generate unique key
}
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Request submitted successfully:');
console.log('Status:', response.data.status);
console.log('Task ID:', response.data.task_id || response.data.tasks_id);
console.log('Request ID:', response.data.request_id);
console.log('Foreign Key:', response.data.foreign_key);
console.log('Publisher:', response.data.publisher_key);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};
// Usage
requestReviews();
import requests
import json
import time
import random
import string
def request_reviews():
url = 'https://data.reviewdata.ai/submit/request-reviews/'
# Generate unique foreign key
timestamp = int(time.time() * 1000)
random_chars = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
foreign_key = f"TEST_{timestamp}_{random_chars}"
payload = {
"job": "App\\Jobs\\RequestReviews",
"data": {
"lazy": True,
"api_key": "YOUR_API_KEY_HERE", # Replace with your API key
"business": {
"id": "restaurant_001",
"name": "McDonald's",
"tags": [
"restaurant",
"pizza",
"italian",
"casual"
],
"phone": "+12123852066",
"address": {
"zip": "10038",
"city": "New York",
"state": "NY",
"street": "160 Broadway",
"country": "USA"
},
"description": "Classic, long-running fast-food chain known for its burgers & fries."
},
"publishers": {
"maps.google.com": {
"profile_key": "https://www.google.com/maps/place/McDonald's/@40.7094789,-74.0126167,886m/data=!3m2!1e3!5s0x89c2592f4977ef97:0xf78d57398ac93494!4m7!3m6!1s0x89c25a177d4bf5db:0x84e51f23e8c0a75c!8m2!3d40.7094789!4d-74.0100364!10e1!16s%2Fg%2F1thtf190!5m1!1e1?entry=ttu&g_ep=EgoyMDI1MDYyMi4wIKXMDSoASAFQAw%3D%3D",
"first_page_only": False,
"last_review_hashes": []
}
},
"foreign_key": foreign_key
}
}
headers = {
'Content-Type': 'application/json'
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print('Request submitted successfully:')
print(f'Status: {result.get("status")}')
print(f'Task ID: {result.get("task_id") or result.get("tasks_id")}')
print(f'Request ID: {result.get("request_id")}')
print(f'Foreign Key: {result.get("foreign_key")}')
print(f'Publisher: {result.get("publisher_key")}')
return result
except requests.exceptions.RequestException as e:
print('Error:', e)
if hasattr(e, 'response') and e.response is not None:
print('Response:', e.response.json())
raise
# Usage
if __name__ == "__main__":
request_reviews()
<?php
function requestReviews() {
$url = 'https://data.reviewdata.ai/submit/request-reviews/';
// Generate unique foreign key
$timestamp = round(microtime(true) * 1000);
$random = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 6);
$foreign_key = "TEST_{$timestamp}_{$random}";
$payload = [
'job' => 'App\\Jobs\\RequestReviews',
'data' => [
'lazy' => true,
'api_key' => 'YOUR_API_KEY_HERE', // Replace with your API key
'business' => [
'id' => 'restaurant_001',
'name' => 'McDonald\'s',
'tags' => [
'restaurant',
'pizza',
'italian',
'casual'
],
'phone' => '+12123852066',
'address' => [
'zip' => '10038',
'city' => 'New York',
'state' => 'NY',
'street' => '160 Broadway',
'country' => 'USA'
],
'description' => 'Classic, long-running fast-food chain known for its burgers & fries.'
],
'publishers' => [
'maps.google.com' => [
'profile_key' => 'https://www.google.com/maps/place/McDonald\'s/@40.7094789,-74.0126167,886m/data=!3m2!1e3!5s0x89c2592f4977ef97:0xf78d57398ac93494!4m7!3m6!1s0x89c25a177d4bf5db:0x84e51f23e8c0a75c!8m2!3d40.7094789!4d-74.0100364!10e1!16s%2Fg%2F1thtf190!5m1!1e1?entry=ttu&g_ep=EgoyMDI1MDYyMi4wIKXMDSoASAFQAw%3D%3D',
'first_page_only' => false,
'last_review_hashes' => []
]
],
'foreign_key' => $foreign_key
]
];
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($payload)
]
];
$context = stream_context_create($options);
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
throw new Exception('Failed to make request');
}
$result = json_decode($response, true);
echo "Request submitted successfully:\n";
echo "Status: " . ($result['status'] ?? 'N/A') . "\n";
echo "Task ID: " . ($result['task_id'] ?? $result['tasks_id'] ?? 'N/A') . "\n";
echo "Request ID: " . ($result['request_id'] ?? 'N/A') . "\n";
echo "Foreign Key: " . ($result['foreign_key'] ?? 'N/A') . "\n";
echo "Publisher: " . ($result['publisher_key'] ?? 'N/A') . "\n";
return $result;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
throw $e;
}
}
// Usage
requestReviews();
?>
Retrieve Task Examples
- JavaScript (Node.js)
- Python
- PHP
const axios = require('axios');
const retrieveTask = async (taskId, foreignKey, publisherKey, apiKey, page = 1, pageSize = 10) => {
try {
const response = await axios.post('https://data.reviewdata.ai/retrieve-task/', {
api_key: apiKey,
task_id: taskId,
foreign_key: foreignKey,
publisher_key: publisherKey,
page: page,
page_size: pageSize
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Task retrieved successfully:');
console.log('Task Status:', response.data.task_status);
console.log('Foreign Key:', response.data.foreign_key);
console.log('Publisher:', response.data.business?.publisher);
if (response.data.reviews) {
console.log('Reviews Count:', response.data.reviews.length);
console.log('Pagination:', response.data.pagination);
}
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};
// Usage with sample data from playground
retrieveTask(
'900e2ff4-2d25-4576-ab18-b9b8e73c0bd6',
'TEST_1751004113518_i6yxcl',
'maps.google.com',
'YOUR_API_KEY_HERE'
);
import requests
def retrieve_task(task_id, foreign_key, publisher_key, api_key, page=1, page_size=10):
url = 'https://data.reviewdata.ai/retrieve-task/'
payload = {
'api_key': api_key,
'task_id': task_id,
'foreign_key': foreign_key,
'publisher_key': publisher_key,
'page': page,
'page_size': page_size
}
headers = {
'Content-Type': 'application/json'
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print('Task retrieved successfully:')
print(f'Task Status: {result.get("task_status")}')
print(f'Foreign Key: {result.get("foreign_key")}')
print(f'Publisher: {result.get("business", {}).get("publisher")}')
if result.get('reviews'):
print(f'Reviews Count: {len(result["reviews"])}')
print(f'Pagination: {result.get("pagination")}')
return result
except requests.exceptions.RequestException as e:
print('Error:', e)
if hasattr(e, 'response') and e.response is not None:
print('Response:', e.response.json())
raise
# Usage with sample data from playground
if __name__ == "__main__":
retrieve_task(
'900e2ff4-2d25-4576-ab18-b9b8e73c0bd6',
'TEST_1751004113518_i6yxcl',
'maps.google.com',
'YOUR_API_KEY_HERE'
)
<?php
function retrieveTask($taskId, $foreignKey, $publisherKey, $apiKey, $page = 1, $pageSize = 10) {
$url = 'https://data.reviewdata.ai/retrieve-task/';
$payload = [
'api_key' => $apiKey,
'task_id' => $taskId,
'foreign_key' => $foreignKey,
'publisher_key' => $publisherKey,
'page' => $page,
'page_size' => $pageSize
];
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($payload)
]
];
$context = stream_context_create($options);
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
throw new Exception('Failed to make request');
}
$result = json_decode($response, true);
echo "Task retrieved successfully:\n";
echo "Task Status: " . ($result['task_status'] ?? 'N/A') . "\n";
echo "Foreign Key: " . ($result['foreign_key'] ?? 'N/A') . "\n";
echo "Publisher: " . ($result['business']['publisher'] ?? 'N/A') . "\n";
if (isset($result['reviews'])) {
echo "Reviews Count: " . count($result['reviews']) . "\n";
echo "Pagination: " . json_encode($result['pagination'] ?? []) . "\n";
}
return $result;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
throw $e;
}
}
// Usage with sample data from playground
retrieveTask(
'900e2ff4-2d25-4576-ab18-b9b8e73c0bd6',
'TEST_1751004113518_i6yxcl',
'maps.google.com',
'YOUR_API_KEY_HERE'
);
?>
Configure Webhook Examples
- JavaScript (Node.js)
- Python
- PHP
const axios = require('axios');
const configureWebhook = async (apiKey, webhookUrl) => {
try {
const response = await axios.post('https://data.reviewdata.ai/webhooks/create-webhook/', {
api_key: apiKey,
webhook: webhookUrl
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Webhook configured successfully:');
console.log('Status:', response.data.status);
console.log('Webhook URL:', response.data.webhook);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};
// Usage
configureWebhook('YOUR_API_KEY_HERE', 'https://example.com/webhook');
import requests
def configure_webhook(api_key, webhook_url):
url = 'https://data.reviewdata.ai/webhooks/create-webhook/'
payload = {
'api_key': api_key,
'webhook': webhook_url
}
headers = {
'Content-Type': 'application/json'
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print('Webhook configured successfully:')
print(f'Status: {result.get("status")}')
print(f'Webhook URL: {result.get("webhook")}')
return result
except requests.exceptions.RequestException as e:
print('Error:', e)
if hasattr(e, 'response') and e.response is not None:
print('Response:', e.response.json())
raise
# Usage
if __name__ == "__main__":
configure_webhook('YOUR_API_KEY_HERE', 'https://example.com/webhook')
<?php
function configureWebhook($apiKey, $webhookUrl) {
$url = 'https://data.reviewdata.ai/webhooks/create-webhook/';
$payload = [
'api_key' => $apiKey,
'webhook' => $webhookUrl
];
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($payload)
]
];
$context = stream_context_create($options);
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
throw new Exception('Failed to make request');
}
$result = json_decode($response, true);
echo "Webhook configured successfully:\n";
echo "Status: " . ($result['status'] ?? 'N/A') . "\n";
echo "Webhook URL: " . ($result['webhook'] ?? 'N/A') . "\n";
return $result;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
throw $e;
}
}
// Usage
configureWebhook('YOUR_API_KEY_HERE', 'https://example.com/webhook');
?>
Alternative Publisher Examples
TripAdvisor Sample Request
- JavaScript (Node.js)
- Python
- PHP
const axios = require('axios');
const requestTripAdvisorReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE',
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: ['restaurant', 'fast-food'],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Fast food restaurant'
},
publishers: {
'tripadvisor.com': {
profile_key: 'https://www.tripadvisor.com/Restaurant_Review-g60763-d123456-Reviews-McDonalds-New_York_City_New_York.html',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`
}
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('TripAdvisor request submitted:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};
// Usage
requestTripAdvisorReviews();
import requests
import time
import random
import string
def request_tripadvisor_reviews():
url = 'https://data.reviewdata.ai/submit/request-reviews/'
# Generate unique foreign key
timestamp = int(time.time() * 1000)
random_chars = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
foreign_key = f"TEST_{timestamp}_{random_chars}"
payload = {
"job": "App\\Jobs\\RequestReviews",
"data": {
"lazy": True,
"api_key": "YOUR_API_KEY_HERE",
"business": {
"id": "restaurant_001",
"name": "McDonald's",
"tags": ["restaurant", "fast-food"],
"phone": "+12123852066",
"address": {
"zip": "10038",
"city": "New York",
"state": "NY",
"street": "160 Broadway",
"country": "USA"
},
"description": "Fast food restaurant"
},
"publishers": {
"tripadvisor.com": {
"profile_key": "https://www.tripadvisor.com/Restaurant_Review-g60763-d123456-Reviews-McDonalds-New_York_City_New_York.html",
"first_page_only": False,
"last_review_hashes": []
}
},
"foreign_key": foreign_key
}
}
headers = {'Content-Type': 'application/json'}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print('TripAdvisor request submitted:', result)
return result
except requests.exceptions.RequestException as e:
print('Error:', e)
if hasattr(e, 'response') and e.response is not None:
print('Response:', e.response.json())
raise
# Usage
if __name__ == "__main__":
request_tripadvisor_reviews()
<?php
function requestTripAdvisorReviews() {
$url = 'https://data.reviewdata.ai/submit/request-reviews/';
// Generate unique foreign key
$timestamp = round(microtime(true) * 1000);
$random = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 6);
$foreign_key = "TEST_{$timestamp}_{$random}";
$payload = [
'job' => 'App\\Jobs\\RequestReviews',
'data' => [
'lazy' => true,
'api_key' => 'YOUR_API_KEY_HERE',
'business' => [
'id' => 'restaurant_001',
'name' => 'McDonald\'s',
'tags' => ['restaurant', 'fast-food'],
'phone' => '+12123852066',
'address' => [
'zip' => '10038',
'city' => 'New York',
'state' => 'NY',
'street' => '160 Broadway',
'country' => 'USA'
],
'description' => 'Fast food restaurant'
],
'publishers' => [
'tripadvisor.com' => [
'profile_key' => 'https://www.tripadvisor.com/Restaurant_Review-g60763-d123456-Reviews-McDonalds-New_York_City_New_York.html',
'first_page_only' => false,
'last_review_hashes' => []
]
],
'foreign_key' => $foreign_key
]
];
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($payload)
]
];
$context = stream_context_create($options);
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
throw new Exception('Failed to make request');
}
$result = json_decode($response, true);
echo "TripAdvisor request submitted: " . json_encode($result) . "\n";
return $result;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
throw $e;
}
}
// Usage
requestTripAdvisorReviews();
?>
Yelp Sample Request
- JavaScript (Node.js)
- Python
- PHP
const axios = require('axios');
const requestYelpReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE',
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: ['restaurant', 'fast-food'],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Fast food restaurant'
},
publishers: {
'yelp.com': {
profile_key: 'https://www.yelp.com/biz/mcdonalds-new-york-123',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`
}
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Yelp request submitted:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};
// Usage
requestYelpReviews();
import requests
import time
import random
import string
def request_yelp_reviews():
url = 'https://data.reviewdata.ai/submit/request-reviews/'
# Generate unique foreign key
timestamp = int(time.time() * 1000)
random_chars = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
foreign_key = f"TEST_{timestamp}_{random_chars}"
payload = {
"job": "App\\Jobs\\RequestReviews",
"data": {
"lazy": True,
"api_key": "YOUR_API_KEY_HERE",
"business": {
"id": "restaurant_001",
"name": "McDonald's",
"tags": ["restaurant", "fast-food"],
"phone": "+12123852066",
"address": {
"zip": "10038",
"city": "New York",
"state": "NY",
"street": "160 Broadway",
"country": "USA"
},
"description": "Fast food restaurant"
},
"publishers": {
"yelp.com": {
"profile_key": "https://www.yelp.com/biz/mcdonalds-new-york-123",
"first_page_only": False,
"last_review_hashes": []
}
},
"foreign_key": foreign_key
}
}
headers = {'Content-Type': 'application/json'}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print('Yelp request submitted:', result)
return result
except requests.exceptions.RequestException as e:
print('Error:', e)
if hasattr(e, 'response') and e.response is not None:
print('Response:', e.response.json())
raise
# Usage
if __name__ == "__main__":
request_yelp_reviews()
<?php
function requestYelpReviews() {
$url = 'https://data.reviewdata.ai/submit/request-reviews/';
// Generate unique foreign key
$timestamp = round(microtime(true) * 1000);
$random = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 6);
$foreign_key = "TEST_{$timestamp}_{$random}";
$payload = [
'job' => 'App\\Jobs\\RequestReviews',
'data' => [
'lazy' => true,
'api_key' => 'YOUR_API_KEY_HERE',
'business' => [
'id' => 'restaurant_001',
'name' => 'McDonald\'s',
'tags' => ['restaurant', 'fast-food'],
'phone' => '+12123852066',
'address' => [
'zip' => '10038',
'city' => 'New York',
'state' => 'NY',
'street' => '160 Broadway',
'country' => 'USA'
],
'description' => 'Fast food restaurant'
],
'publishers' => [
'yelp.com' => [
'profile_key' => 'https://www.yelp.com/biz/mcdonalds-new-york-123',
'first_page_only' => false,
'last_review_hashes' => []
]
],
'foreign_key' => $foreign_key
]
];
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($payload)
]
];
$context = stream_context_create($options);
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
throw new Exception('Failed to make request');
}
$result = json_decode($response, true);
echo "Yelp request submitted: " . json_encode($result) . "\n";
return $result;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
throw $e;
}
}
// Usage
requestYelpReviews();
?>
Tips for Using the Examples
1. Replace API Key
Replace the sample API key YOUR_API_KEY_HERE
with your actual API key from https://www.shoutaboutus.com/request-api-key.
2. Test with Playground First
Before using these examples in production, test your requests with the interactive playground to ensure they work correctly.
3. Handle Errors Gracefully
All examples include error handling. Make sure to implement proper error handling in your production code.
4. Use Unique Foreign Keys
The examples generate unique foreign keys to avoid conflicts. In production, use your own unique identifier system.
5. Monitor Task Status
After submitting a request, use the retrieve task endpoint to check the status and get the results when complete.
6. Implement Webhooks
For production use, implement webhooks to receive real-time notifications when tasks are completed.
Common Use Cases
1. Submit Request and Wait for Completion
- JavaScript (Node.js)
- Python
- PHP
const submitAndWait = async () => {
// Submit request
const submitResponse = await requestReviews();
const taskId = submitResponse.task_id || submitResponse.tasks_id;
const foreignKey = submitResponse.foreign_key;
// Poll for completion
let completed = false;
while (!completed) {
await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30 seconds
const taskData = await retrieveTask(taskId, foreignKey, 'maps.google.com', 'YOUR_API_KEY_HERE');
if (taskData.task_status === 200) {
completed = true;
console.log('Task completed with', taskData.reviews.length, 'reviews');
} else if (taskData.task_status >= 400) {
throw new Error('Task failed');
}
}
};
import time
def submit_and_wait():
# Submit request
submit_response = request_reviews()
task_id = submit_response.get('task_id') or submit_response.get('tasks_id')
foreign_key = submit_response.get('foreign_key')
# Poll for completion
completed = False
while not completed:
time.sleep(30) # Wait 30 seconds
task_data = retrieve_task(task_id, foreign_key, 'maps.google.com', 'YOUR_API_KEY_HERE')
if task_data.get('task_status') == 200:
completed = True
print(f'Task completed with {len(task_data.get("reviews", []))} reviews')
elif task_data.get('task_status', 0) >= 400:
raise Exception('Task failed')
<?php
function submitAndWait() {
// Submit request
$submitResponse = requestReviews();
$taskId = $submitResponse['task_id'] ?? $submitResponse['tasks_id'];
$foreignKey = $submitResponse['foreign_key'];
// Poll for completion
$completed = false;
while (!$completed) {
sleep(30); // Wait 30 seconds
$taskData = retrieveTask($taskId, $foreignKey, 'maps.google.com', 'YOUR_API_KEY_HERE');
if ($taskData['task_status'] == 200) {
$completed = true;
echo 'Task completed with ' . count($taskData['reviews']) . ' reviews' . "\n";
} elseif ($taskData['task_status'] >= 400) {
throw new Exception('Task failed');
}
}
}
?>
2. Bulk Business Processing
- JavaScript (Node.js)
- Python
- PHP
const businesses = [
{ name: 'Business 1', profileKey: 'https://...' },
{ name: 'Business 2', profileKey: 'https://...' }
];
const processBulk = async () => {
const tasks = [];
for (const business of businesses) {
const response = await requestReviews(); // Modify with business data
tasks.push(response);
}
// Process all tasks
for (const task of tasks) {
// Retrieve and process each task
}
};
businesses = [
{'name': 'Business 1', 'profile_key': 'https://...'},
{'name': 'Business 2', 'profile_key': 'https://...'}
]
def process_bulk():
tasks = []
for business in businesses:
response = request_reviews() # Modify with business data
tasks.append(response)
# Process all tasks
for task in tasks:
# Retrieve and process each task
pass
<?php
$businesses = [
['name' => 'Business 1', 'profile_key' => 'https://...'],
['name' => 'Business 2', 'profile_key' => 'https://...']
];
function processBulk() {
global $businesses;
$tasks = [];
foreach ($businesses as $business) {
$response = requestReviews(); // Modify with business data
$tasks[] = $response;
}
// Process all tasks
foreach ($tasks as $task) {
// Retrieve and process each task
}
}
?>
Need Help?
If you need assistance with these examples:
- Test in Playground: Use the interactive playground to test requests
- Check Documentation: Review the API documentation for details
- Contact Support: Email techsupport@shoutaboutus.com for help