REST : try to automate the "GET" task of a sale that is made on magento without making the call and same with the PUT method

by Olivier Rolland   Last Updated April 05, 2017 12:09 PM

I try to automate the "GET" task of a sale that is made on magento, without making the call, how can I proceed? I would like the inventory to update in my json file and I receive it in an external folder.and I would also do the reverse when my inventory changes in my external folder that can PUT in my magento. I would also like to be able to get back the "sku" as well as the "qty", these are the two important data for me. I managed to make my calls in REST with this code but maybe SOAP would open other possibilities to me, what do you think?

that's my calls in REST for the PUT

<?php

session_start();

try {

    $oauthClient = new OAuth($consumerKey, $consumerSecret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);

    $oauthClient->setToken($token, $tokensecret);

    $oauthClient->enableDebug();

    $resourceUrl = $apiUrl.'/stockitems/1';

    $headers = array('Content-Type' => 'application/json', 'Accept' => 'application/json');

    $productData = json_encode(array(
    "qty"=> "287.0000"
    ));

    $oauthClient->fetch($resourceUrl, $productData, OAUTH_HTTP_METHOD_PUT, $headers);

    print_r($oauthClient->getLastResponseInfo());                                                                   

} 
catch (OAuthException $e) 
{
   print_r($e->getMessage());

   echo "&lt;br/&gt;";

   print_r($e->lastResponse);

}
?>

and after i will work with a .json file and not an array in my .php file



Related Questions


Magento 2 SOAP API setSpecialPrice

Updated July 31, 2018 14:09 PM

How to develop a SOAP API as a guest user

Updated June 26, 2018 16:09 PM


SOAP connection problems after 1.9.3.0 update

Updated October 23, 2016 09:03 AM

How to check if product is created from SOAP

Updated December 30, 2016 08:03 AM