Sending PUT data through PHP cURL
For PHP Developers, trying to write a RESTful API can sometimes get a little clunky, especially when you're working with PUT. Here's how send a PUT request using cURL in PHP:
$data = array("woo" => "coderwall");
$ch = curl_init();
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);
Written by Marlon Landaverde
Related protips
1 Response
Hi, thanks for this. Really helpful! Just wondering how I add the URL for the API to this script please?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#