xml - eBay Trading API - Not connecting - Time out -


i've got application exchanges data ebay trading api using php/xml. it's been working fine 3 weeks since yesterday wasn't able connect anymore.

for simplicity, i've created simple script test communication, i'm still stuck same problem.

//show errors - useful whilst developing error_reporting(e_all);  // these keys can obtained registering @ http://developer.ebay.com  $production = true;   // toggle true if going against production $compatabilitylevel = 833;    // ebay api version $siteid = 3;                            // siteid needed in request - us=0, uk=3, de=77...  if ($production) {     $devid = '[devid]';   // these prod keys different sandbox keys     $appid = '[appid]';     $certid = '[certid]';      //set server use (sandbox or production)     $serverurl = 'https://api.ebay.com/ws/api.dll';      // server url different prod , sandbox     //the token representing ebay user assign call     $usertoken = '[my_token]'; }  class ebaysession {      private $requesttoken;     private $devid;     private $appid;     private $certid;     private $serverurl;     private $compatlevel;     private $siteid;     private $verb;      /**     __construct       constructor make new instance of ebaysession details needed make call       input:    $userrequesttoken - authentication token fir user making call       $developerid - developer key obtained when registered @ http://developer.ebay.com       $applicationid - application key obtained when registered @ http://developer.ebay.com       $certificateid - certificate key obtained when registered @ http://developer.ebay.com       $usetestserver - boolean, if true sandbox server used, otherwise production server used       $compatabilitylevel - api version compatable       $sitetouseid - id of ebay site associate call iwht (0 = us, 2 = canada, 3 = uk, ...)       $callname  - name of call being made (e.g. 'getebayofficialtime')       output:   response string returned server      */     public function __construct($userrequesttoken, $developerid, $applicationid, $certificateid, $serverurl, $compatabilitylevel, $sitetouseid, $callname) {         $this->requesttoken = $userrequesttoken;         $this->devid = $developerid;         $this->appid = $applicationid;         $this->certid = $certificateid;         $this->compatlevel = $compatabilitylevel;         $this->siteid = $sitetouseid;         $this->verb = $callname;         $this->serverurl = $serverurl;     }      /**     sendhttprequest       sends http request server session       input:    $requestbody       output:   http response string      */     public function sendhttprequest($requestbody) {         //build ebay headers using variables passed via constructor         $headers = $this->buildebayheaders();          //initialise curl session         $connection = curl_init();         //set server using (could sandbox or production server)         curl_setopt($connection, curlopt_url, $this->serverurl);          //stop curl verifying peer's certificate         curl_setopt($connection, curlopt_ssl_verifypeer, 0);         curl_setopt($connection, curlopt_ssl_verifyhost, 0);          curl_setopt($connection, curlopt_verbose, true);         curl_setopt($connection, curlopt_timeout, 30);          //set headers using array of headers         curl_setopt($connection, curlopt_httpheader, $headers);          //set method post         curl_setopt($connection, curlopt_post, 1);          //set xml body of request         curl_setopt($connection, curlopt_postfields, $requestbody);          //set return transfer string curl_exec         curl_setopt($connection, curlopt_returntransfer, 1);          //send request         $response = curl_exec($connection);          //close connection         curl_close($connection);          //return response         return $response;     }      /**     buildebayheaders       generates array of string used headers http request ebay       output:   string array of headers applicable call      */     private function buildebayheaders() {         $headers = array(             //regulates versioning of xml interface api             'x-ebay-api-compatibility-level: ' . $this->compatlevel,             //set keys             'x-ebay-api-dev-name: ' . $this->devid,             'x-ebay-api-app-name: ' . $this->appid,             'x-ebay-api-cert-name: ' . $this->certid,             //the name of call requesting             'x-ebay-api-call-name: ' . $this->verb,             //siteid must set in request's xml             //siteid = 0  (us) - uk = 3, canada = 2, australia = 15, ....             //siteid indicates ebay site associate call             'x-ebay-api-siteid: ' . $this->siteid,         );          return $headers;     }  } ?>  <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">         <title>getebayofficialtime</title>     </head>     <body>  <?php //siteid must set in request's xml //siteid = 0  (us) - uk = 3, canada = 2, australia = 15, .... //siteid indicates ebay site associate call $siteid = 3; //the call being made: $verb = 'getebayofficialtime'; //level / amount of data call return (default = 0) $detaillevel = 0;  ///build request xml string $requestxmlbody = '<?xml version="1.0" encoding="utf-8" ?>'; $requestxmlbody .= '<getebayofficialtimerequest xmlns="urn:ebay:apis:eblbasecomponents">'; $requestxmlbody .= "<requestercredentials><ebayauthtoken>$usertoken</ebayauthtoken></requestercredentials>"; $requestxmlbody .= '</getebayofficialtimerequest>';  //create new ebay session details pulled in included keys.php $session = new ebaysession($usertoken, $devid, $appid, $certid, $serverurl, $compatabilitylevel, $siteid, $verb); //send request , response $responsexml = $session->sendhttprequest($requestxmlbody); if (stristr($responsexml, 'http 404') || $responsexml == '')     die('<p>error sending request');  //xml string parsed , creates dom document object $responsedoc = new domdocument(); $responsedoc->loadxml($responsexml);   //get error nodes $errors = $responsedoc->getelementsbytagname('errors');  //if there error nodes if ($errors->length > 0) {     echo '<p><b>ebay returned following error(s):</b>';     //display each error     //get error code, shortmesaage , longmessage     $code = $errors->item(0)->getelementsbytagname('errorcode');     $shortmsg = $errors->item(0)->getelementsbytagname('shortmessage');     $longmsg = $errors->item(0)->getelementsbytagname('longmessage');     //display code , shortmessage     echo '<p>', $code->item(0)->nodevalue, ' : ', str_replace(">", "&gt;", str_replace("<", "&lt;", $shortmsg->item(0)->nodevalue));     //if there long message (ie errorlevel=1), display     if (count($longmsg) > 0)         echo '<br>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longmsg->item(0)->nodevalue)); } else { //no errors     //get node containing time , display contents     $ebaytime = $responsedoc->getelementsbytagname('timestamp');     echo '<p><b>the official ebay time ', $ebaytime->item(0)->nodevalue, ' gmt</b>'; } ?>      </body> </html> 

this output:

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">         <title>getebayofficialtime</title>     </head>     <body>  * connect() api.ebay.com port 443 (#0) *   trying 66.135.211.100... * timeout *   trying 66.135.211.140... * timeout *   trying 66.211.179.150... * timeout *   trying 66.211.179.180... * timeout *   trying 66.135.211.101... * timeout *   trying 66.211.179.148... * timeout * connect() timed out! * closing connection #0 <p>error sending request 

facts:

  1. i've tested script in 2 different servers.
  2. i've made same call on ebay online testing tool, , it's working fine ebay dev keys.
  3. nothing has changed code since problem started happen.

anyone has had similar issues? ideas?

thanks!

just update: problem between hosting service (1&1) , ebay. (1&1) told me ebay every , again blocks ip addresses connect api. took me couple of days able connect ebay api, there nothing wrong application. so, it's worth checking server hosting provider being blocked ebay.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -