Project

General

Profile

API - Shopping - Price alert

URL: /alerta-pret/1234/
Method: POST
Required field: price
Optional fields: customer_name, customer_email

Code sample:

$api_id = 1;
$api_key = 'testpass';
$hostname = 'https://example.com'; // no trailing slash

# fetch data
$url = '/alerta-pret/1234/';
$post_data = array(
    'customer_name' => 'John Doe',
    'customer_email' => 'test@example.com',
    'price' => 12.34
);
$user_token = 'xxx'; // is required here. Get it from Your DB after Token generation
$extra_headers = array(
    'X-API-ID: ' . $api_id,
    'X-API-Hash: ' . md5($api_key . $url. http_build_query($post_data)),
    'X-User-Token: ' . $user_token
);

header('Content-Type: application/json; charset=utf-8');
echo sendRequest($hostname . $url, $post_data, $extra_headers);

Succes message

{
    has_error: false,
    messages: [ ],
    results: {
        request_status: "ok",
        request_message: "" 
    }
}

Error message

{
    has_error: true,
    messages: [
        "Adresa de e-mail introdusa nu este valida",
        "Pretul dorit (123,45 lei) trebuie sa fie mai mic decat pretul curent (59,99 lei)" 
    ],
    results: [ ]
}

Go to top