Friday, 15 March 2013

How to specify --form parameter and PUT argument in php curl ? -



How to specify --form parameter and PUT argument in php curl ? -

i have execute curl command in php:

curl --digest -u yourapikey:yourapisecret "http://api.moodstocks.com/v2/ref/yourid" --form image_file=@"image.jpg" -x set

so far have this:

function ms_addimage($file, $hash_id){ $postdata = array("image_file" => "@/".realpath($file)); $opts[curlopt_url] = $this->api_base_url . "ref/".$hash_id; $opts[curlopt_verbose] =1; $opts[curlopt_post] =true; $opts[curlopt_postfields] =$postdata; $ch = curl_init(); curl_setopt_array($ch, $opts); $raw_resp = curl_exec($ch); echo "response " . $raw_resp . "\n"; curl_close($ch); }

the file path right missing something. how pass --form parameter , set argument?

so missing following:

$opts[curlopt_customrequest] = "put";

now working.

php curl

No comments:

Post a Comment