Példák
Minta API kulcsos azonosításhoz
Az alábbi PHP példa alapján áttekinthetőek az API hívás szükséges lépései. Természetesen bármilyen programozási nyelven megvalósítható ugyanez a felépítés.
<?php
//////////////////////////////////////////////////
/// curl init
$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
///////////////////////////////////////////////////////////////////
/// login
$request='<qqqxml version="1.0" encoding="UTF-8" qqq>
<Params>
<ApiKey>abc123</ApiKey>
<WebshopInfo>true</WebshopInfo>
</Params>';
curl_setopt($curl, CURLOPT_URL, "https://api.unas.eu/shop/login");
curl_setopt($curl, CURLOPT_POSTFIELDS,$request);
$response = curl_exec($curl);
$xml=simplexml_load_string($response);
$token=(string)$xml->Token;
///////////////////////////////////////////////////////////////////
/// getOrder
$headers=array();
$headers[]="Authorization: Bearer ".$token;
$request='<qqqxml version="1.0" encoding="UTF-8" qqq>
<Params>
<Key>123456</Key>
</Params>';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, "https://api.unas.eu/shop/getOrder");
curl_setopt($curl, CURLOPT_POSTFIELDS,$request);
$response = curl_exec($curl);
echo $response;
///////////////////////////////////////////////////////////////////
/// getProduct
$headers=array();
$headers[]="Authorization: Bearer ".$token;
$request='<qqqxml version="1.0" encoding="UTF-8" qqq>
<Params>
<Id>654321</Id>
</Params>';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, "https://api.unas.eu/shop/getProduct");
curl_setopt($curl, CURLOPT_POSTFIELDS,$request);
$response = curl_exec($curl);
echo $response;
?>