CS-Cart API and PHP cURL

I am trying to communicate via the API for CS-Cart and having some troubles. I am able to fetch data successfully, but not putting data. I have tried the helper class in this forum as well as regular PHP cURL requests.



I get this error: “Method Not Allowed: O” Status: 405.



It would help if anyone had any working examples of PHP cURL using “PUT”. I do not use mod_rewrite for this. So my calls are towards example:

“api.php?_d=orders&order_id=1”



My code (Real passwords, usernames and url is omitted in example):

--------------------------------------------------------------------

$order_data = json_encode(array(‘timestamp’ => 1382548160) );

$order_id = “13752”;

$query_string = “?_d=orders&order_id=$order_id”;



$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);

curl_setopt($ch, CURLOPT_URL, ‘http://example.com/api.php’.$query_string);

curl_setopt($ch, CURLOPT_USERPWD, $usr . “:” . $pass);

curl_setopt($ch, CURLOPT_POSTFIELDS,$order_data);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

‘Content-Type: application/json’,

'Content-Length: ’ . strlen($order_data))

);



$result = curl_exec($ch);



echo $result;

curl_close($ch);



--------------------------------------------------------------------



Hope any one can help. :)

I found the answer at last. It was in the URL. It should be:

“?_d=orders/$order_id”

thanks for posting the update. Small syntactical issues like this can drive one crazy but now, I'll be able to search for the answer.

[quote name='GauNodac' timestamp='1382739486' post='170401']

I found the answer at last. It was in the URL. It should be:

“?_d=orders/$order_id”

[/quote] I would like to do the same , but can not find api.php ? any idea ? .thanks…

[quote name='rolex' timestamp='1398294848' post='182225']

I would like to do the same , but can not find api.php ? any idea ? .thanks…

[/quote]



The api.php is in your server: {project_path}/shop/api.php

I believe that if they are using the free version that api.php does not exist.

[quote name='gorka' timestamp='1398704257' post='182540']

The api.php is in your server: {project_path}/shop/api.php

[/quote] thanks for the the info

Hello Everyone,



I have implemented the code from “GauNodac” post and I updated my test order status to “Complete”:

$order_data = json_encode(array('status' => 'C') );



It works fine, but the only problem is CS-Cart doesn't send an order status update notification emails to the customer. Does anybody know how to fix that please?



Thank you in advance!