Skip to main content
All CollectionsIntegrationsOther Ecommerce Platforms
Queuing Review Invitations using PHP code
Queuing Review Invitations using PHP code
Mollie Herbert avatar
Written by Mollie Herbert
Updated over a week ago

If we don’t provide a plugin that suits your requirements, then we have provided this starting point for anyone who wants to write custom PHP code to queue review invitations.


Requirements

⭐️ Available on our Grow plan and above


Navigation 📍

To use this, you would need to use the API Credentials.

  • Login to your REVIEWS.IO Account

  • Select Integrations

  • Select API


PHP Code

<?php
$store = 'STORE-ID-GOES-HERE';
$apikey = 'API-KEY-GOES-HERE';

// Set headers for the API request
$headersRequest = array(
"store: " . $store,
"apikey: " . $apikey,
"Content-Type: application/json"
);

// Prepare the body of the request
$bodyRequest = array(
"name" => "Demo Customer",
"email" => "demo-email@reviews.co.uk",
"order_id" => 12345,
"products" => array(
array(
"sku" => "123",
"name" => "Test Product",
"image" => "http://www.reviews.co.uk/test-image.jpg",
"pageUrl" => "https://www.reviews.co.uk/test-product"
)
)
);

// Function to send API request
function sendApiRequest($url, $headers, $body) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}

// Send Merchant Invitation
$merchantUrl = 'https://api.reviews.co.uk/merchant/invitation';
$merchantResponse = sendApiRequest($merchantUrl, $headersRequest, $bodyRequest);
print_r($merchantResponse);

// Send Product Invitation
$productUrl = 'https://api.reviews.co.uk/product/invitation';
$productResponse = sendApiRequest($productUrl, $headersRequest, $bodyRequest);
print_r($productResponse);
?>

Note: Please make sure to replace STORE-ID-GOES-HERE and API-KEY-GOES-HERE with actual values.

Did this answer your question?