Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.34 KB | None | 0 0
  1. <?php require_once('keys.php') ?>
  2. <?php require_once('eBaySession.php') ?>
  3. <?php session_start(); ?>
  4. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <HTML>
  6. <HEAD>
  7. <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  8. <TITLE>Get eBay User Items (Result)</TITLE>
  9. </HEAD>
  10. <BODY>
  11. <h2>Testing eBay Connection Plugin</h2>
  12. <h3>Receiving User Tocken</h3>
  13. <h4>With a User Tocken ID we can import user data to our website.</h4>
  14.  
  15. <?php
  16.  
  17.  
  18. //SiteID must also be set in the Request's XML
  19. //SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, ....
  20. //SiteID Indicates the eBay site to associate the call with
  21. $siteID = 0;
  22. //the call being made:
  23. $verb = 'FetchToken';
  24.  
  25. ///Build the request Xml string
  26. $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
  27. $requestXmlBody .= '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
  28. $requestXmlBody .= '<SessionID>'.$_SESSION["eBaySession"].'</SessionID>';
  29. $requestXmlBody .= '</FetchTokenRequest>';
  30.  
  31.  
  32. //Create a new eBay session with all details pulled in from included keys.php
  33. $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
  34.  
  35. //send the request and get response
  36. $responseXml = $session->sendHttpRequest($requestXmlBody);
  37. if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
  38. die('<P>Error sending request');
  39.  
  40. //Xml string is parsed and creates a DOM Document object
  41. $responseDoc = new DomDocument();
  42. $responseDoc->loadXML($responseXml);
  43.  
  44.  
  45. //get any error nodes
  46. $errors = $responseDoc->getElementsByTagName('Errors');
  47.  
  48. //if there are error nodes
  49. if($errors->length > 0)
  50. {
  51. echo '<P><B>eBay returned the following error(s):</B>';
  52. //display each error
  53. //Get error code, ShortMesaage and LongMessage
  54. $code = $errors->item(0)->getElementsByTagName('ErrorCode');
  55. $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage');
  56. $longMsg = $errors->item(0)->getElementsByTagName('LongMessage');
  57. //Display code and shortmessage
  58. echo '<P>', $code->item(0)->nodeValue, ' : ', str_replace(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue));
  59. //if there is a long message (ie ErrorLevel=1), display it
  60. echo '<BR/>User Session ID: '.$_COOKIE["eBaySession"].'';
  61. if(count($longMsg) > 0)
  62. echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue));
  63.  
  64. }
  65.  
  66. else //no errors
  67. {
  68. //get the nodes needed
  69. $eBayAuthTokenNode = $responseDoc->getElementsByTagName('eBayAuthToken');
  70.  
  71. //Display the details
  72. //echo '<BR/>User Session ID: '.$_SESSION["eBaySession"].'';
  73. //echo '<BR/><BR/>User Token: '.$eBayAuthTokenNode->item(0)->nodeValue.'';
  74. $verb = 'GetSellerList';
  75. $username = $_GET["username"];
  76. $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()); //current time
  77. $CreateTimeTo = date('Y-m-d', strtotime("+3 months", strtotime($CreateTimeFrom)));
  78.  
  79. $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
  80. $requestXmlBody .= '<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
  81. $requestXmlBody .= '<UserID>'.$username.'</UserID>';
  82. $requestXmlBody .= '<DetailLevel>ReturnAll</DetailLevel>';
  83. $requestXmlBody .= '<ErrorLanguage>RFC 3066</ErrorLanguage>';
  84. $requestXmlBody .= '<WarningLevel>Low</WarningLevel>';
  85. $requestXmlBody .= '<Version>987</Version>';
  86. $requestXmlBody .= '<RequesterCredentials><eBayAuthToken>'.$eBayAuthTokenNode->item(0)->nodeValue.'</eBayAuthToken></RequesterCredentials>';
  87. $requestXmlBody .= '<StartTimeFrom>'.$CreateTimeFrom.'</StartTimeFrom>';
  88. $requestXmlBody .= '<StartTimeTo>'.$CreateTimeTo.'</StartTimeTo>';
  89. $requestXmlBody .= '<EndTimeFrom>'.$CreateTimeFrom.'</EndTimeFrom>';
  90. $requestXmlBody .= '<EndTimeTo>'.$CreateTimeTo.'</EndTimeTo>';
  91.  
  92. $requestXmlBody .= '<Pagination><EntriesPerPage>200</EntriesPerPage></Pagination>';
  93. $requestXmlBody .= '<OutputSelector>ItemArray.Item.Title</OutputSelector>';
  94. $requestXmlBody .= '<OutputSelector>ItemArray.Item.Description</OutputSelector>';
  95. $requestXmlBody .= '<OutputSelector>ItemArray.Item.BuyItNowPrice</OutputSelector>';
  96. $requestXmlBody .= '<OutputSelector>ItemArray.Item.Quantity</OutputSelector>';
  97. $requestXmlBody .= '</GetSellerListRequest>';
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. //Create a new eBay session with all details pulled in from included keys.php
  106. $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
  107.  
  108. //send the request and get response
  109. $responseXml = $session->sendHttpRequest($requestXmlBody);
  110. if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
  111. die('<P>Error sending request');
  112.  
  113. //Xml string is parsed and creates a DOM Document object
  114. $responseDoc = new DomDocument();
  115. $responseDoc->loadXML($responseXml);
  116. $html = $responseDoc->saveHTML();
  117. //echo $html;
  118.  
  119.  
  120.  
  121.  
  122. echo $responseXml;
  123.  
  124. }
  125.  
  126.  
  127. //SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, ....
  128. //SiteID Indicates the eBay site to associate the call with
  129. $siteID = 0;
  130. //the call being made:
  131. $verb = 'GetSellerList';
  132. //Time with respect to GMT
  133. //by default retreive orders in last 30 minutes
  134. $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-1800); //current time minus 30 minutes
  135. $CreateTimeTo = gmdate("Y-m-d\TH:i:s");
  136. //If you want to hard code From and To timings, Follow the below format in "GMT".
  137. //$CreateTimeFrom = YYYY-MM-DDTHH:MM:SS; //GMT
  138. //$CreateTimeTo = YYYY-MM-DDTHH:MM:SS; //GMT
  139. ///Build the request Xml string
  140.  
  141.  
  142. //by default retreive orders in last 30 minutes
  143. $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-1800); //current time minus 30 minutes
  144. $CreateTimeTo = gmdate("Y-m-d\TH:i:s");
  145.  
  146.  
  147. //send the request and get response
  148. $responseXml = $session->sendHttpRequest($requestXmlBody);
  149. if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
  150. die('<P>Error sending request');
  151.  
  152. //Xml string is parsed and creates a DOM Document object
  153. $responseDoc = new DomDocument();
  154. $responseDoc->loadXML($responseXml);
  155.  
  156. $title_nodes = $responseDoc->getElementsByTagName('Title');
  157. $titles = array();
  158. foreach ($title_nodes as $node) {
  159. $titles[] = $node->nodeValue;
  160. }
  161.  
  162. ?>
  163.  
  164. </BODY>
  165. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement