Hier vind je alle 'ins en outs' van rePricer

Autorisatie

Onze API werkt met een public/private key waarmee je per request een hash genereert.
Updated 3 weeks ago

Genereren van een hash

function generateHash($public_key, $private_key, $method, $endpoint, $data)
{
    $timestamp = date("U");
    $hash_string = array($public_key,$method,$endpoint,$data,$timestamp);
    $hash = hash_hmac('sha512',implode('|',$hash_string),$private_key);    
    return array('X-Auth: '.$public_key, 'X-Hash: '.$hash, 'X-Date: '.$timestamp);
}

PHP voorbeeld om je verkoopkanalen op te halen

<?php

$api = 'https://app.repricer.nl';
$endpoint = '/api/v1/channels/all.json';
$method = 'GET';
$public_key = '123456789-123';
$private_key = '987654321-987';

// Generate the CURL headers to authenticate our request
$headers = generateHash($public_key, $private_key, $method, $endpoint, $data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$api.$endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);

print_r($result);

function generateHash($public_key, $private_key, $method, $endpoint, $data)
{
    $timestamp = date("U");
    $hash_string = array($public_key,$method,$endpoint,$data,$timestamp);
    $hash = hash_hmac('sha512',implode('|',$hash_string),$private_key);    
    return array('X-Auth: '.$public_key, 'X-Hash: '.$hash, 'X-Date: '.$timestamp);
}
Did this answer your question?