Skip to content

Instantly share code, notes, and snippets.

@AurelienLavorel
Created December 30, 2018 15:41
Show Gist options
  • Select an option

  • Save AurelienLavorel/f08b41a42dab73771ffa3a4e2be4ed1a to your computer and use it in GitHub Desktop.

Select an option

Save AurelienLavorel/f08b41a42dab73771ffa3a4e2be4ed1a to your computer and use it in GitHub Desktop.
Magento SOAP API call example
Contain the downloaded SOAP WSDL, you can copy paste it from /soap/?wsdl_list
<?php
libxml_disable_entity_loader(false);
$userData = array("username" => "xxx", "password" => "xxx");
$domain = "https://www.example.com";
$request = new SoapClient($domain . "/index.php/soap/?wsdl&services=integrationAdminTokenServiceV1", array("soap_version" => SOAP_1_2));
$token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken($userData);
$opts = array(
'http'=>array(
'header' => 'Authorization: Bearer '.json_decode($token->result)
)
);
$wsdlUrl = $domain . '/soap/default?wsdl&services=directoryCurrencyInformationAcquirerV1';
$wsdlUrl = $domain . '/soap/default?wsdl&services=salesOrderRepositoryV1';
$context = stream_context_create($opts);
$soapClient = new SoapClient("s.xml", ['version' => SOAP_1_2, 'context' => $context, 'trace' => true]);
$soapResponse = $soapClient->__getFunctions();
print_r($soapResponse);
try {
print_r($soapClient->salesOrderRepositoryV1GetList());
} catch (Exception $e) {
echo($soapClient->__getLastResponse());
echo PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment