question

webly_wobly avatar image
0 Likes"
webly_wobly asked ·

eBay Trading API PHP SOAP functional example

Hi All,

 

I searched high and low for a functional example of how to use the eBay Trading API's with PHP SOAP protocol, and either I am terrible at searching, or as I suspect, there really aren't any great examples of how to do it that don't involve using a bloated, ancient SDK.  Since PHP now has its own built in SOAP capabilities, I was determined to figure out how to use it.  With that being said, I offer to the eBay developer community a functional piece of code that makes a GetUser call, which can be easily modified for pretty much any eBay Trading API call.  This was written and tested on PHP 5.3.  Hope someone finds this helpful.

 


 

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

$mytoken = "YOUR TOKEN";
$devId = "YOUR DEV ID";
$appId = "YOUR APP ID";
$certId = "YOUR CERT ID";
$wsdl_url = 'http://developer.ebay.com/webservices/latest/ebaySvc.wsdl';
$apiCall = "GetUser";
$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));                

$params = array('Version' => 803, 'DetailLevel' => 'ReturnSummary', 'UserID' => 'webly_wobly');  //set the API call parameters

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

print_d($request); // print the API call results in a nice readable format

//echo "<br><br><br><br>REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";   // this lets you view the XML of your last call which can be helpful

?>

php-soap-example-trading
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

InactiveAutoUser avatar image
0 Likes"
InactiveAutoUser answered ·

Hi

it looks like there may be an issue with latest  WSDL provided by ebay, change version to 849.

You are probably using latest one which is 851 that was released 05/12/2013

If your SOAP client cached previous one then when cached expired and was calling to refresh it it may got the broken one.

see http://developer.ebay.com/DevZone/XML/docs/ReleaseNotes.html

· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

aurelio756 avatar image
0 Likes"
aurelio756 answered ·

hello, the code worked fine until yesterday, now I get this error

 

Fatal error: SOAP-ERROR: Parsing Schema: unexpected <any> in complexType in /home/mhd-01/www.mysite.net/htdocs/ebay-manager/includes/test.php on line 13

can you help me?? thanks!

 

· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

epinapala avatar image
0 Likes"
epinapala ,

Best Regards,

Eswara Rajesh Pinapala,

eBay Dvelopers Program Site Engineer.

answered ·

Thanks for the Soap sample.

· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.