rest - PHP cURL HTTP PUT -
i trying create http put request curl , can't make work. i've read many tutorials none of them worked. here's current code:
$filedata = array('metadata' => $rdfxml); $ch = curl_init($url); $header = "content-type: multipart/form-data; boundary='123456f'"; curl_setopt($ch, curlopt_verbose, 1); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_customrequest, "put"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_httpheader, array($header)); curl_setopt($ch, curlopt_postfields, http_build_query($filedata)); $returned = curl_exec($ch); if (curl_error($ch)) { print curl_error($ch); } else { print 'ret: ' .$returned; }
i've tried using php pear got same result. problem repository says no metadata has been set. need help! thanks!
just been doing myself today... here code have working me...
$data = array("a" => $a); $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_customrequest, "put"); curl_setopt($ch, curlopt_postfields,http_build_query($data)); $response = curl_exec($ch); if (!$response) { return false; }
src: http://www.lornajane.net/posts/2009/putting-data-fields-with-php-curl
Comments
Post a Comment