Dec 3, 2015
0
Level 13
Consume an API that serve images
Hi, I would like to consume an API that serves imagery and serve the returned imagery to my users. The API accepts a number of parameters where my users provide those parameters and then I would like to forward that request to an API then return the corresponding image.
I created the following but it seems to be missing something:
$url = 'http://example.com/api/url/' ;
$body = Input::all();
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_HTTPHEADER, array("accept : image/webp,image/*,*/*;q=0.8"));
curl_setopt($c, CURLOPT_POSTFIELDS, $body);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($c);
Please or to participate in this conversation.