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

Guixt issue
Hello all,

We are experiencing the following problem with Guixt:

Some transact

Typedef struct vs just struct
Anyone know the rationale for using typedef for structs when a struct is itself a typedef? I have s

need help in update query
hi
i have a dynamic form. i need help in how can i use update query when values from dynamic for

SAP Logon Failed
I tried to login to SAP through MMC.

When i click start and give password.

it

Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Mes

PHP5 - Verifying a secure mail is secure
I need to send an e-mail from a form to a external department and because it contains personal custo

Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

Simple MySQL query...
Hello,
How could I do a mysql query that does this: SELECT * WHERE date/time < 5minutes ag

php email checker
I am having alot of trouble finding info on how to do these email things. I need to do the following

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