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

Session is not saving
I am not trying to do anything too fancy, I am just trying to get some $_SESSION data to save and us

Table control is disappearing from Screen
Hi Experts,

I have a screen with multiple table control(TC). Each table control has two c

Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?

data type in column definition
Hi,
I create a table with column called "Direction of Travel code ".
The travel codes in t

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

Hi, explode and strstr.
Hi, I seem to be confused about the strstr function, eg. i have a string like:
"a.b.c.d.e.f&

Just a white page
Okay so, my website, when I click SignUp on it it takes me to /join.php but its a complete white pag

Need a fuction to count entries in a field
Hi
I need a fuction to count how many times a email address is entered in to a field.

I ma

calculator
I can't figure out why this code doesn't work. No error messages. Page loads.

Code: <

VAT
how should I deal with VAT?

if I have a product that costs £5.00 and VAT @ 17.5% (£0.87

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