try {
// Replace the following variables with your own key management
// $APPLICATION_KEY
// $APPLICATION_ID
// $USER_ID
// $SECRET_KEY - this is the same key (skey) used when logging on userr
$userId = $USER_ID;
$secretKey = $SECRET_KEY;
$appId = $APPLICATION_ID;
$appKey = $APPLICATION_KEY;
$publicServiceUrl = 'https://api.tradera.com/v3/PublicService.asmx';
$publicServiceUrlWithAuth = $publicServiceUrl
. '?appId=' . $appId
. '&appKey=' . $appKey;
$publicClient = new SoapClient(
$publicServiceUrl . '?WSDL',
array('location' => $publicServiceUrlWithAuth)
);
// Parameters for call to FetchToken
$fetchTokenParams = new StdClass();
$fetchTokenParams -> userId = $userId;
$fetchTokenParams -> secretKey = $secretKey;
// Make SOAP call
$fetchTokenResponse = $publicClient -> FetchToken($fetchTokenParams);
// Handle result
echo 'Token: ' . $fetchTokenResponse -> FetchTokenResult -> AuthToken . PHP_EOL
. 'Expires: ' . $fetchTokenResponse -> FetchTokenResult -> HardExpirationTime . PHP_EOL;
}
catch(SoapFault $soapFault) {
echo 'Error: ' . $soapFault->faultstring;
}
|