PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Translate a PHP script to windev httprequest calls
Translate a PHP script to windev httprequest calls
Iniciado por guest, 17,feb. 2016 07:45 - No hay respuesta
Publicado el 17,febrero 2016 - 07:45
Hello,

I have a PHP script example to handle api calls to a webserver, but i didn't fix it to translate this to windev httprequest commands can somebody help me ??

<?php

// or live API: https://plazaapi.bol.com
$url = 'https://test-plazaapi.bol.com';
$uri = '/services/rest/orders/v1/open';

// your public key
$public_key = 'public_key';

//your private key
$private_key = 'private_key';

$port = 443;
$contenttype = 'application/xml';
$date = gmdate('D, d M Y H:i:s T');
$httpmethod = 'GET';

$signature_string = $httpmethod . "\ \ ";
$signature_string .= $contenttype . "\ ";
$signature_string .= $date."\ ";
$signature_string .= "x-bol-date:" . $date . "\ ";
$signature_string .= $uri;
$signature = $public_key.':'.base64_encode(hash_hmac('SHA256', $signature_string, $private_key, true));

// Setup CURL (One can also opt to use sockets or http libraries, but CURL is a versatile, widespread solution)
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: ".$contenttype, "X-BOL-Date:".$date, "X-BOL-Authorization: ".$signature));
curl_setopt($ch, CURLOPT_URL, $url.$uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$result = curl_exec($ch);

// Check if there were any errors.
if(curl_errno($ch)) {
print_r(curl_errno($ch), true);
}

// Clean up after ourselves
curl_close($ch);
?>