php - Notice: Trying to get property 'AuthToken' of non-object
one text
I am getting an error while executing code.
Notice: Trying to get property 'AuthToken' of non-object
Anyone please tell me why this error come and what is the solution
here is the code
$fields = [
"HS_ChannelId"=>$HS_ChannelId,
"HS_IsRedirectionRequest"=>$HS_IsRedirectionRequest,
"HS_MerchantId"=> $HS_MerchantId,
"HS_StoreId"=> $HS_StoreId,
"HS_ReturnURL"=> $HS_ReturnURL,
"HS_MerchantHash"=> $HS_MerchantHash,
"HS_MerchantUsername"=> $HS_MerchantUsername,
"HS_MerchantPassword"=> $HS_MerchantPassword,
"HS_TransactionReferenceNumber"=> $HS_TransactionReferenceNumber,
"HS_RequestHash"=> $hashRequest
];
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
$handshake = json_decode($result);
$AuthToken = $handshake->AuthToken;
Source