Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('keys.php') ?>
- <?php require_once('eBaySession.php') ?>
- <?php session_start(); ?>
- <!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>Get eBay User Items (Result)</TITLE>
- </HEAD>
- <BODY>
- <h2>Testing eBay Connection Plugin</h2>
- <h3>Receiving User Tocken</h3>
- <h4>With a User Tocken ID we can import user data to our website.</h4>
- <?php
- //SiteID must also be set in the Request's XML
- //SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, ....
- //SiteID Indicates the eBay site to associate the call with
- $siteID = 0;
- //the call being made:
- $verb = 'FetchToken';
- ///Build the request Xml string
- $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
- $requestXmlBody .= '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
- $requestXmlBody .= '<SessionID>'.$_SESSION["eBaySession"].'</SessionID>';
- $requestXmlBody .= '</FetchTokenRequest>';
- //Create a new eBay session with all details pulled in from included keys.php
- $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
- //send the request and get response
- $responseXml = $session->sendHttpRequest($requestXmlBody);
- if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
- die('<P>Error sending request');
- //Xml string is parsed and creates a DOM Document object
- $responseDoc = new DomDocument();
- $responseDoc->loadXML($responseXml);
- //get any error nodes
- $errors = $responseDoc->getElementsByTagName('Errors');
- //if there are error nodes
- if($errors->length > 0)
- {
- echo '<P><B>eBay returned the following error(s):</B>';
- //display each error
- //Get error code, ShortMesaage and LongMessage
- $code = $errors->item(0)->getElementsByTagName('ErrorCode');
- $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage');
- $longMsg = $errors->item(0)->getElementsByTagName('LongMessage');
- //Display code and shortmessage
- echo '<P>', $code->item(0)->nodeValue, ' : ', str_replace(">", ">", str_replace("<", "<", $shortMsg->item(0)->nodeValue));
- //if there is a long message (ie ErrorLevel=1), display it
- echo '<BR/>User Session ID: '.$_COOKIE["eBaySession"].'';
- if(count($longMsg) > 0)
- echo '<BR>', str_replace(">", ">", str_replace("<", "<", $longMsg->item(0)->nodeValue));
- }
- else //no errors
- {
- //get the nodes needed
- $eBayAuthTokenNode = $responseDoc->getElementsByTagName('eBayAuthToken');
- //Display the details
- //echo '<BR/>User Session ID: '.$_SESSION["eBaySession"].'';
- //echo '<BR/><BR/>User Token: '.$eBayAuthTokenNode->item(0)->nodeValue.'';
- $verb = 'GetSellerList';
- $username = $_GET["username"];
- $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()); //current time
- $CreateTimeTo = date('Y-m-d', strtotime("+3 months", strtotime($CreateTimeFrom)));
- $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
- $requestXmlBody .= '<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
- $requestXmlBody .= '<UserID>'.$username.'</UserID>';
- $requestXmlBody .= '<DetailLevel>ReturnAll</DetailLevel>';
- $requestXmlBody .= '<ErrorLanguage>RFC 3066</ErrorLanguage>';
- $requestXmlBody .= '<WarningLevel>Low</WarningLevel>';
- $requestXmlBody .= '<Version>987</Version>';
- $requestXmlBody .= '<RequesterCredentials><eBayAuthToken>'.$eBayAuthTokenNode->item(0)->nodeValue.'</eBayAuthToken></RequesterCredentials>';
- $requestXmlBody .= '<StartTimeFrom>'.$CreateTimeFrom.'</StartTimeFrom>';
- $requestXmlBody .= '<StartTimeTo>'.$CreateTimeTo.'</StartTimeTo>';
- $requestXmlBody .= '<EndTimeFrom>'.$CreateTimeFrom.'</EndTimeFrom>';
- $requestXmlBody .= '<EndTimeTo>'.$CreateTimeTo.'</EndTimeTo>';
- $requestXmlBody .= '<Pagination><EntriesPerPage>200</EntriesPerPage></Pagination>';
- $requestXmlBody .= '<OutputSelector>ItemArray.Item.Title</OutputSelector>';
- $requestXmlBody .= '<OutputSelector>ItemArray.Item.Description</OutputSelector>';
- $requestXmlBody .= '<OutputSelector>ItemArray.Item.BuyItNowPrice</OutputSelector>';
- $requestXmlBody .= '<OutputSelector>ItemArray.Item.Quantity</OutputSelector>';
- $requestXmlBody .= '</GetSellerListRequest>';
- //Create a new eBay session with all details pulled in from included keys.php
- $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
- //send the request and get response
- $responseXml = $session->sendHttpRequest($requestXmlBody);
- if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
- die('<P>Error sending request');
- //Xml string is parsed and creates a DOM Document object
- $responseDoc = new DomDocument();
- $responseDoc->loadXML($responseXml);
- $html = $responseDoc->saveHTML();
- //echo $html;
- echo $responseXml;
- }
- //SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, ....
- //SiteID Indicates the eBay site to associate the call with
- $siteID = 0;
- //the call being made:
- $verb = 'GetSellerList';
- //Time with respect to GMT
- //by default retreive orders in last 30 minutes
- $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-1800); //current time minus 30 minutes
- $CreateTimeTo = gmdate("Y-m-d\TH:i:s");
- //If you want to hard code From and To timings, Follow the below format in "GMT".
- //$CreateTimeFrom = YYYY-MM-DDTHH:MM:SS; //GMT
- //$CreateTimeTo = YYYY-MM-DDTHH:MM:SS; //GMT
- ///Build the request Xml string
- //by default retreive orders in last 30 minutes
- $CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-1800); //current time minus 30 minutes
- $CreateTimeTo = gmdate("Y-m-d\TH:i:s");
- //send the request and get response
- $responseXml = $session->sendHttpRequest($requestXmlBody);
- if(stristr($responseXml, 'HTTP 404') || $responseXml == '')
- die('<P>Error sending request');
- //Xml string is parsed and creates a DOM Document object
- $responseDoc = new DomDocument();
- $responseDoc->loadXML($responseXml);
- $title_nodes = $responseDoc->getElementsByTagName('Title');
- $titles = array();
- foreach ($title_nodes as $node) {
- $titles[] = $node->nodeValue;
- }
- ?>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement