Using cURL to PUT


Posted on 16th Feb 2014 07:03 pm by admin

Can somebody help with the correct php code to make a cURL PUT request. Here is a sample of code below that uses POST, but I need to modify this one so that it uses PUT instead.

Code: <?php

//Modify these
$API_KEY = 'xxx';
$SECRET = 'yyy';
$TOKEN = 'zzz';
$STORE_URL = 'sss.myshopify.com';

$url = 'https://' . $API_KEY . ':' . md5($SECRET . $TOKEN) . '@' . $STORE_URL . '/admin/products.xml';

$xmlsrc = <<<XML
SOMETHING WILL GO HERE
XML;

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlsrc);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

if(ereg("^(https)",$url)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false);

$result = curl_exec($session);

curl_close($session);

echo $result; // this shows exactly what you'd expect to see, as given in API documentation

?>

No comments posted yet

Your Answer:

Login to answer
135 Like 35 Dislike
Previous forums Next forums
Other forums

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

db entry based on primary key
My "topics" table contains 10 entires
*--------------*
topicid topic
------

Access website from only 1 computer...?
One of my customers wants his website to only be accessed by people in which they bought the website

Problem with shopcart code
Hello, I am having a bit of trouble being able to add a product to my shopcart. My mysql database i

mysql timestamp manipulation
How could I use a timestamp (e.g 2009-10-30 13:20:35 ), and with php find out if it is:

from

Query failed issue with php script but works fine in mssql manager!
hi i have the script below which copies data from one table to another but will only insert new data

PHP Surveys
I really would like some advice.

If you have a client come to you asking for a survey to be d

reorder sql query
ok so i have this very simple code:
Code: $query = "SELECT search_keywords, COUNT(search_key

random generation
hi

i need help with generating this

numbers from 1-12

i want to generate in ran

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash