PHP cURL HTTP PUT

Just been doing that myself today… here is code I have working for 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

What is the main difference between PATCH and PUT request?

HTTP verbs are probably one of the most cryptic things about the HTTP protocol. They exist, and there are many of them, but why do they exist? Rails seems to want to support many verbs and add some verbs that aren’t supported by web browsers natively. Here’s an exhaustive list of http verbs: http://annevankesteren.nl/2007/10/http-methods There … Read more

Is there any way to do HTTP PUT in python

I’ve used a variety of python HTTP libs in the past, and I’ve settled on requests as my favourite. Existing libs had pretty useable interfaces, but code can end up being a few lines too long for simple operations. A basic PUT in requests looks like: payload = {‘username’: ‘bob’, ’email’: ‘bob@bob.com’} >>> r = … Read more

How to send a POST request with BODY in swift

If you are using Alamofire v4.0+ then the accepted answer would look like this: let parameters: [String: Any] = [ “IdQuiz” : 102, “IdUser” : “iosclient”, “User” : “iosclient”, “List”: [ [ “IdQuestion” : 5, “IdProposition”: 2, “Time” : 32 ], [ “IdQuestion” : 4, “IdProposition”: 3, “Time” : 9 ] ] ] Alamofire.request(“http://myserver.com”, method: … Read more

How to send PUT, DELETE HTTP request in HttpURLConnection?

To perform an HTTP PUT: URL url = new URL(“http://www.example.com/resource”); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); httpCon.setDoOutput(true); httpCon.setRequestMethod(“PUT”); OutputStreamWriter out = new OutputStreamWriter( httpCon.getOutputStream()); out.write(“Resource content”); out.close(); httpCon.getInputStream(); To perform an HTTP DELETE: URL url = new URL(“http://www.example.com/resource”); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); httpCon.setDoOutput(true); httpCon.setRequestProperty( “Content-Type”, “application/x-www-form-urlencoded” ); httpCon.setRequestMethod(“DELETE”); httpCon.connect();

RAW POST using cURL in PHP

I just found the solution, kind of answering to my own question in case anyone else stumbles upon it. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, “http://url/url/url” ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, “body goes here” ); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/plain’)); $result = curl_exec($ch);

Curl and PHP – how can I pass a json through curl by PUT,POST,GET

PUT $data = array(‘username’=>’dog’,’password’=>’tall’); $data_json = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’,’Content-Length: ‘ . strlen($data_json))); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘PUT’); curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); POST $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’)); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)