Skip to content

Instantly share code, notes, and snippets.

@Andrew-Myers-Webtise
Created June 22, 2016 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew-Myers-Webtise/1c9d1c1ba1f34e92fd10ed067a596446 to your computer and use it in GitHub Desktop.
Save Andrew-Myers-Webtise/1c9d1c1ba1f34e92fd10ed067a596446 to your computer and use it in GitHub Desktop.
Magento SOAP V2 API test script.
<?php
/**
* soaptest.php
* Use in terminal. E.g. php soaptest.php > myfilename.txt
*/
// Some setup
$inc_id = "100012345";
$http = "https://www.example.com";
$login_user = "magento_user_id";
$api_key = "your_api_key_here";
$proxy = new SoapClient($http . '/index.php/api/v2_soap?wsdl=1');
$sessionId = $proxy->login($login_user, $api_key);
// salesOrderList test example. Provides a smaller output of an order. Comment out to skip. Change filter if need be.
echo "Sales Order List: state:processing | increment_id:", $inc_id;
echo "\n";
echo "----------------------------------------------------------------------------------------";
echo "\n";
$filter = array('filter' => array(array('key' => 'state', 'value' => 'processing'), array('key' => 'increment_id', 'value' => $inc_id)));
$result = $proxy->salesOrderList($sessionId, $filter);
var_dump ($result);
// salesOrderInfo test example. Has the most info on an order. Comment out to skip
echo "\n";
echo "Sales Order Info: increment_id:", $inc_id;
echo "\n";
echo "----------------------------------------------------------------------------------------";
echo "\n";
$result = $proxy->salesOrderInfo($sessionId, $inc_id);
var_dump( $result );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment