How to Get Order Data from Ebay account Through API Call

eBay API Get Orders: To get the ebay sales order data from via api call. First you have an ebay developer account access. Get your ebay access token from ebay developer account and dev id, app id, cert id.

Wsdl for getting ebay order data : http://developer.ebay.com/webservices/latest/ebaySvc.wsdl

This api call belong to Ebay Trading section. Use GetOrders ebay api method to gat order data.

Create Ebay API Get Orders API Call:

<?php

function print_d($array){    echo "<pre>\n";    print_r($array);    echo "</pre>\n";}

$mytoken = "Use ebay access token here";
$devId = "**********Use Dev Id Here**********";
$appId = "**********Use App Id here**********";
$certId = "********* Use Cert Id Here***********";

$wsdl_url = 'http://developer.ebay.com/webservices/latest/ebaySvc.wsdl';

$apiCall = "GetOrders";

$credentials = array('AppId' => $appId, 'DevID' => $devId, 'AuthCert' => $certId);

$client = new SOAPClient($wsdl_url, array('trace' => 1, 'exceptions' => 0, 'location' => "https://api.ebay.com/wsapi?callname=$apiCall&appid=$appId&siteid=0&version=803&Routing=new"));

$eBayAuth = array('eBayAuthToken' => new SoapVar($mytoken, XSD_STRING, NULL, NULL, NULL, 'urn:ebay:apis:eBLBaseComponents'),
                    'Credentials' => new SoapVar ($credentials, SOAP_ENC_OBJECT, NULL, NULL, NULL, 'urn:ebay:apis:eBLBaseComponents'));  
                    
$header_body = new SoapVar($eBayAuth, SOAP_ENC_OBJECT);    

$header = array(new SOAPHeader('urn:ebay:apis:eBLBaseComponents', 'RequesterCredentials', $header_body));                

//set the API call parameters

$params = array('Version' => 803, 'CreateTimeFrom'=>'2014-03-18T01:01:02.768Z', 'CreateTimeTo'=>'2014-03-20T01:01:02.768Z', 'OrderRole'=>'Seller');  

$request = $client->__soapCall($apiCall, array($params), NULL, $header);  //make the actual API call

print_d($request);

In above code we get seller order data as API response. As you see in the parameter we put “OrderRole” to Seller. You can change as per requirement like Buyer.

We can fetch order on the basis of CreateTimeFrom to CreateTimeTo basis. Their are many other filtration parameters available on ebay trading api documentation.

Similar Posts

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *