I am trying to access a web service that returns a jpeg image. It requires two variables, time_sent and user_id, in the URL## Heading ##.
Here is my code:
$ch = curl_init();
$options = array(
CURLOPT_URL => 'www.example.com/service/?time_sent=time&user_id=user',
CURLOPT_HTTPHEADER => array('Authorization-Token:' . $api_key, 'Content-type: image/jpeg'),
CURLOPT_ENCODING => "",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPGET => true,
CURLOPT_CONNECTTIMEOUT => 60,
CURLOPT_TIMEOUT => 60
);
}
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if(!curl_errno($ch)){
curl_close($ch);
$img = imagecreatefromstring($response);
imagejpeg($img);
imagedestroy($img);
}
else{
curl_close($ch);
return curl_error($ch);
}
Here is my output:
ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality ÿÛC $.' ",#(7),01444'9=82<.342ÿÛC
2!!22222222222222222222222222222222222222222222222222ÿÀÈ•"ÿÄ
ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚<br> %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ?ê¡ñ…n¦TþÌ)Ÿö« ¾Òü1g¤ýºâ5† ¼7ñW5¢xVÑõhXïØ¿6Ö¦|Wß}¤,&¼øÆ2‰´£.b&^Äè÷s)ùê“xkáÕÔª¯ª\¯÷~uÿâk—³ðóN¬îQ*Ëxq¢]ÂUoø (rÈèWÁ~R˹:ý^³ï<áe•Z¾æþÕ’Ú[$Lå¾ía\Þ*3)o—ýšÖ<Ò(éæðŒåêˆÊ+VòþÑ4VÓ„ß2ÿyŒ×›ÔÊû¿Þ¨µ%PÊìÌÕŒ§Ìuu ªíß¿o÷k2æõ.%ûì«þõs¯xïº ¶ê9b(È»s>ÖÜ›æ©lüAqoÕÙ«(¾æçîÔEUºSäˆæŸâ¿ò¼Õº’¤¨®Ž¬µåÙ¾]Õ¥i¬ÜÙºì—å_á¨äÑÓk3|ÕËx·^¢ujþ‹Å~»ä—ø¿Ú¬Ýy[ûA?º”cÊ8™òîÿj˜?Öí©vî¦lÚû«Qšqí1šŠ‰±E2¡4H•õm«÷k–ø†ÒÞø¢ÊÍÓ÷®êêtiâK®_/Þ¬]7^+ó6+Ä©÷·W$yyKŸÅÌe$B$Ø‹M¹e··i–²µmQ–gŠÙÕ]k*Ù5=YÒßÍÜÎßuj£b¹½ÒY®.õyÚÒÆ•Ÿø–¦¶ø_¬N-ʲ(þõïxfÓF²‹÷<em>éyltö@ªrVð‡,N~{ÈùwXðãØM·gûß5bM¦²¯ÿe^ãâû+ifw ªª¿7ûÕ暌Vêÿ#n¨æ÷¹#ÊqO§ÿµP2íêµÐÏ2ðµ›-»V„Jizvê±5¿Ë÷j©ù~SAŸ("í}Õ,Ëòn¦V½SLÉ䪊`Coq-¼©,mµ–¶ŸWûz'™þµWkµXiÑJÈô´¹TÕbæÊæÞ(¦’DºÍVô;xµ$µ··\<¿:ÿ³]Ĩ~Ýi...etc
Can anyone tell me what I am doing wrong?