ik heb een stukje PHP code, en zou willen weten hoe dit om te zetten is naar Delphi ( bv met behulp van Indy )
via Google heb ik wel e.e.a. gevonden, maar kan nergens vinden hoe te handelen met de username en password
kan iemand mij a.u.b. op weg helpen (ik gebruik XE2 VCL) ?
PHP Code:
$username = '#username#';
$password = '#password#';
$customerID = '0';
$options = array();
//Send request
$curl = curl_init('http://abc.def.com/api/v1/products/list');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
'Username' => $username,
'Password' => $password,
'CustomerID' => $customerID,
'Options' => json_encode($options),
));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
//Decode request
$resultDecoded = json_decode($result, true);
//Error decoding
if(!$resultDecoded){
echo 'Unknown error:<br /><br />';
echo $result;
}
//Error request
else if($resultDecoded['ErrorCode'] != 0){
echo 'Error (' . $resultDecoded['ErrorCode'] . '):<br />' . $resultDecoded['ErrorMessage'];
}
//No error
else{
echo '<pre>';
print_r($resultDecoded['Result']);
echo '</pre>';
}
Bookmarks