api - How to do I format this curl command in PHP
I'am trying build a PHP call to my first API and the example request shown in the docs, tell me to make this request with curl but I'am not having much success. I've tried to follow other answers (i.e. CURL php query formation - how to? ) and know i'am doing something wrong but can't seem to figure it out?
Any help would be greatly appreciated.
The initial request must be authorized with HTTP Basic authorization.
POST /api/shrink HTTP/1.1
Host: api.site.org
Authorization: Basic YXsdflasdkfjalsdjfojiosslkjdZdXZ3eHl6MDEyMzQ1
curl -i --user api:api_key --data-binary @test.png http://api.site.org
This should return a json string that includes a url to an image file.
Answer
Solution:
Should be something like this:
Answer
Solution:
I think it would go something like this:
You have the
-i
flag, but i'm not sure if you want to have the response header, in case you do addCURLOPT_HEADER => 1
too to the mix. Also if you don't want to output the response as of the php process's output, useCURLOPT_RETURNTRANSFER => 1
and you will get the response back from curl init.Answer
Solution:
Looks to me that all the information you need can be found here
The cURL function
curl_setopt
allows you to set your curl options that best suit you.Hope this helps. =)