Sending Custom Header with CURL

garrettotter

New Member
I want to send a request to a web service via an API as shown below, i have to passa custom http header(Hash), i'm using CURL, my code seems to work but I'm not gettingthe rigth response, I'm told it has to do with the hash value, though the value hasbeen seen to be correct, is there anything wrong with the way I'm passing it or withthe code itself. I want to send a request to a web service via an API as shown below, i have to passa custom http header(Hash), I'm using CURL, my code seems to work but I'm not gettingthe right response, I'm told it has to do with the hash value, though the value hasbeen seen to be correct, is there anything wrong with the way I'm passing it or withthe code itself.\[code\] <?php $ttime=time(); $hash="123"."$ttime"."dfryhmn"; $hash=hash("sha512","$hash"); $curl = curl_init(); curl_setopt($curl,CURLOPT_HTTPHEADER,array('Hash:$hash')); curl_setopt ($curl, CURLOPT_URL, 'http://web-service-api.com/getresult.xml?clientid=456&time=$ttime'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $xml = curl_exec ($curl); if ($xml === false) { die('Error fetching data: ' . curl_error($curl)); } curl_close ($xml); echo htmlspecialchars("$xml", ENT_QUOTES); ?>\[/code\]
 
Back
Top