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

Removing Title From database problem
Hi again ! i am having an issue with updating database. When i update any price of a title it remove

update 2 columns by doing inner 2-column query
Hi,
is something like this possible?

update contract_all set col1,col2 =
(

shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just

Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

convert PHP array to Javascript array
I have a page that gets a request sent from AJAX, and I am trying to convert a PHP array to a javasc

Writting a script to arrange images........ need some help
Ok so here is the link

http://hmtotc.com/dev/projects/vrassociates/jeweler_dev/admin/index.ph

How would I protect......
I have a from, actually, a good amount of forms. How can I make it so you can't type the characters:

How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.

So today is 10/20/2009, i need to fig

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

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