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

Did you know?Explore Trending and Topic pages for more stories like this.
//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

Rss feed question
Hi

My blog and my website are different. Am i able to take my rss feed
from my blog and p

Passing variables with pagination - iterating through unique id per link
Hi everyone,
I have seen a few topics like this one. Still cant find the specific thing, so I am

Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message

textfield unchanged
hi,
i want my form to know whether its textbox is unchange or not.

if($textbox == 'unchang

radio button reamains checked
Hello i'm trying to keep the state off my radio buttons so it shows which ones where clicked after t

CODE NOT WORKING
Code: [Select]<?php
//include shared codes

include '../lib/common.php';
include

php calculate
this code echoes correctly the sum but the inserted result is 0??
Code: <?php
$TotalNum

Problem with php's rename function
So, i'm having a problem with the php rename function. Basically my script 'delete_user.php' attempt

Material xxx does not exist in plant xxx
Dear All,

I am working for a steel project which is repetitive manufacturing.

Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on

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