Operation
The request should be structured in a table for the idWebsite (your technical identifier) and the message (understood to be the required data) can be sent via an HTTP POST request:
https://www.verified-reviews.com/index.php?action=act_api_notification_sha1&type=json2
{
"idWebsite": "fd5445fb-4468-4947-adb6-5051429d88ad",
"message": {
"order_ref": "ref100",
"firstname": "John",
"lastname": "Doe",
"email": "john@doe.com",
"order_date": "2019-01-01 12:00:00",
"sign": "5051429d88addsd65247zaedesdw5sdsz561s92eis",
"products": {
"0": {
"id_product": 100,
"name_product": "My Product 100"
},
"1": {
"id_product": 200,
"name_product": "My Product 200"
}
}
Any variable transmitted in the Webservice must be encoded in JSON.
Below is an example request in PHP:
<?PHP
$ID_WEBSITE = "12gthd5g-erg1-hdgy-yfh5-gfdf12548vfd";
$SECURE_KEY = "ghsyehf5-hfyd-gets-195g-hgets125dhre";
$URL_AV = "http://www.avis-verifies.com/index.php";
/**
*
* Send a request
*
**/
echo "<br><br>== API Notification ==<br>";
$descNotification = array(
'query' => 'pushCommandeSHA1', //Required
'order_ref' => 'order-12125', //Required - Reference order
'email' => 'john@doe.com', //Required - Client email
'lastname' => 'Doe', //Required - Client lastname
'firstname' => 'John', //Required - Client firstname
'order_date' => '2015-05-17 09:39:00', //Required - Format YYYY-MM-JJ HH:MM:SS
'delay' => '0', //0=Immediately / ‘n’ days between 1 and 30 days
'PRODUCTS' => array(
0=>array(
'id_product' => 'ref001', //Required - Product Id
'name_product' => 'My Product ref001', //Required - Product Name
'url_product' => 'http://www.mywebsite.com/products/ref001.html',
'url_product_image' => 'http://www.mywebsite.com/img/products/ref001.jpg',
'GTIN_UPC' => 'GTIN_UPC',
'GTIN_EAN' => 'GTIN_EAN',
'GTIN_JAN' => 'GTIN_JAN',
'GTIN_ISBN' => 'GTIN_ISBN',
'MPN' => 'MPN',
'sku' => 'sku',
'brand_name' => 'brand_name',
),
1=>array(
'id_product' => 'ref002', //Required - Product Id
'name_product' => 'My Product ref002', //Required - Product Name
)
),
'sign' => '',
);
$descNotification['sign']=SHA1($descNotification['query'].$descNotification['order_ref'].$descNotification['email'].$descNotification['lastname'].$descNotification['firstname'].$descNotification['order_date'].$descNotification['delay'].$SECURE_KEY);
$encryptedNotification=http_build_query(
array(
'idWebsite' => $ID_WEBSITE,
'message' => json_encode($descNotification)
)
);
$postNotification = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $encryptedNotification
)
);
$contextNotification = stream_context_create($postNotification);
$resultNotification = file_get_contents($URL_AV.'?action=act_api_notification_sha1&type=json2', false, $contextNotification);
echo $resultNotification,"<br><br>\n";
$resultNotification = json_decode($resultNotification,true);
echo "==RETURN==[";
echo $resultNotification['return'];
echo "]<br><br>\n";
echo $resultNotification['debug'];
if($resultNotification['return'] == 1) {
echo "==> OK <br>";
// Success
} else {
echo "==> ERROR <br>";
// Error, please check the array returned
}
?>
Signature calculation
The signature should be integrated with the message board to authorize the call to our Webservice.
The complete data set should be preferably encoded in UTF-8.
It is calculated using the SHA1 method from the concatenation of certain past data to which we add your secret key:
sign = SHA1(‘query’ + ‘order_ref’ + ‘email’ + ‘lastname’ + ‘firstname’ + ‘order_date’ + ‘delay’ + ‘secret_key’)
Return message
The absorption information is transmitted back to you in a new table.
You can thus decode the return message in JSON according to the following list of codes:
- Your transaction is absorbed by the system
- Signature calculation is incorrect
- The idWebsite doesn't exist
- The parameters are incorrect