Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9087321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:40:33+00:00 2026-06-16T21:40:33+00:00

I am new to the eBay API and currently developing in PHP, I have

  • 0

I am new to the eBay API and currently developing in PHP, I have managed to use GetItem to import details of an order based on the Item ID to my website’s database. But What I want to do now is to link a users account to my website and import their listings to my database. I have put the code I used for GetItem (below) but now I am stuck and I don’t know what to use, GetAccount, GetUser or GetSellerList to:

First: have my user redirected from my website to eBay to authorize my application to access his/her listings.

Second: Import that listing (an echo would be enough for now) to my website.

This is my code for GetItem:

     require_once('keys.php');
     require_once('eBaySession.php');

    if(isset($_POST['Id']))
    {
        //Get the ItemID inputted
        $id = $_POST['Id'];


        //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 = 101;
        //the call being made:
        $verb = 'GetItem';

        ///Build the request Xml string
        $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
        $requestXmlBody .= '<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
        $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthToken></RequesterCredentials>";;
        $requestXmlBody .= "<ItemID>$id</ItemID>";
        $requestXmlBody .= '</GetItemRequest>';

        //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(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue));
            //if there is a long message (ie ErrorLevel=1), display it
            if(count($longMsg) > 0)
                echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue));

        }

        else //no errors
        {
            //get the nodes needed
            $titleNode = $responseDoc->getElementsByTagName('Title');
            $primaryCategoryNode = $responseDoc->getElementsByTagName('PrimaryCategory');
            $categoryNode = $primaryCategoryNode->item(0)->getElementsByTagName('CategoryName');
            $listingDetailsNode = $responseDoc->getElementsByTagName('ListingDetails');
            $startedNode = $listingDetailsNode->item(0)->getElementsByTagName('StartTime');
            $endsNode = $listingDetailsNode->item(0)->getElementsByTagName('EndTime');

            $ShippingPackageDetailsNode = $responseDoc->getElementsByTagName('ShippingPackageDetails');
            if ($ShippingPackageDetailsNode->length > 0) {
                $packageDepthNode = $ShippingPackageDetailsNode->item(0)->getElementsByTagName('PackageDepth');
                $DepthUnit = $packageDepthNode->item(0)->getAttribute('unit');
                $packageLengthNode = $ShippingPackageDetailsNode->item(0)->getElementsByTagName('PackageLength');
                $LengthUnit = $packageLengthNode->item(0)->getAttribute('unit');
                $packageWidthNode = $ShippingPackageDetailsNode->item(0)->getElementsByTagName('PackageWidth');
                $WidthUnit = $packageWidthNode->item(0)->getAttribute('unit');
            }

            $sellingStatusNode = $responseDoc->getElementsByTagName('SellingStatus');
            $currentPriceNode = $sellingStatusNode->item(0)->getElementsByTagName('CurrentPrice');
            $currency = $currentPriceNode->item(0)->getAttribute('currencyID');
            $startPriceNode = $responseDoc->getElementsByTagName('StartPrice');
            $buyItNowPriceNode = $responseDoc->getElementsByTagName('BuyItNowPrice');
            $bidCountNode = $sellingStatusNode->item(0)->getElementsByTagName('BidCount');

            $sellerNode = $responseDoc->getElementsByTagName('Seller');

            //Display the details
            echo '<P><B>', $titleNode->item(0)->nodeValue, " ($id)</B>";
            echo '<BR>Category: ', $categoryNode->item(0)->nodeValue;
            echo '<BR>Started: ', $startedNode->item(0)->nodeValue;
            echo '<BR>Ends: ', $endsNode->item(0)->nodeValue;

            if ($ShippingPackageDetailsNode->length > 0) {
                echo "<BR>Package Length: ", $packageLengthNode->item(0)->nodeValue, ' '.$LengthUnit.'';
                echo "<BR>Package Width: ", $packageWidthNode->item(0)->nodeValue, ' '.$WidthUnit.'';
                echo "<BR>Package Depth: ", $packageDepthNode->item(0)->nodeValue, ' '.$DepthUnit.'';
            }

            echo "<P>Current Price: ", $currentPriceNode->item(0)->nodeValue, $currency;
            echo "<BR>Start Price: ", $startPriceNode->item(0)->nodeValue, $currency;
            echo "<BR>BuyItNow Price: ", $buyItNowPriceNode->item(0)->nodeValue, $currency;
            echo "<BR>Bid Count: ", $bidCountNode->item(0)->nodeValue;

            //Display seller detail if present
            if($sellerNode->length > 0)
            {
                echo '<P><B>Seller</B>';
                $userIDNode = $sellerNode->item(0)->getElementsByTagName('UserID');
                $scoreNode = $sellerNode->item(0)->getElementsByTagName('FeedbackScore');
                $regDateNode = $sellerNode->item(0)->getElementsByTagName('RegistrationDate');

                echo '<BR>UserID: ', $userIDNode->item(0)->nodeValue;
                echo '<BR>Feedback Score: ', $scoreNode->item(0)->nodeValue;
                echo '<BR>Registration Date: ', $regDateNode->item(0)->nodeValue;
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:40:33+00:00Added an answer on June 16, 2026 at 9:40 pm

    After reading a lot of poor documentation on eBay about it’s API and getting crazy! I took matters in to my own hands and made a step by step guide about the API and figured out a way to do this. Which I will try to explain as simple as possible. (Using PHP)

    What we will do:

    1. Create an application
    2. Get a Session ID for our user from eBay
    3. Connect to eBay using Session ID
    4. User grants access to our application to link to his user account
      (using Session ID)
    5. User Token generated
    6. Our website receives User Token for future uses (to access user data
      on eBay)

    First
    You would need two PHP files called: keys.php and eBaySession.php which are found in eBay’s PHP SDK which is located in eBay’s Developers website Documentations. (https://www.x.com/developers/ebay/documentation-tools/sdks)

    Second
    You will include these two files in a new PHP file which will also hold the user interface.

    Third
    You will create an account on eBay’s Developers website and create a new application.

    Fourth
    You will obtain sandbox and production keys for your application using your developers account. Then you will generate a sandbox user and obtain a user token. (via My Account Page)

    It could be a bit hard to find yourself around on eBay’s Developers website but you will find the hang of it eventually.

    Fifth
    You will insert the DEV, APP, CERT and UserToken of your application in the keys.php file (both for production and sand-box modes)

    Sixth
    You would require a RuName, which is also located in the My Account Page (Manage Your RuNames).

    Seventh
    You will now insert the RuName in your keys.php file as a new parameter:

    $RuName = 'your RuName key';
    

    So our keys.php will look like this:

    <?php
        //show all errors - useful whilst developing
        error_reporting(E_ALL);
    
        // these keys can be obtained by registering at http://developer.ebay.com
    
        $production         = true;   // toggle to true if going against production
        $compatabilityLevel = 551;    // eBay API version
    
        if ($production) {
            $devID = 'production dev id';   // these prod keys are different from sandbox keys
            $appID = 'production app id';
            $certID = 'production cert id';
            $RuName = 'production RuName';
            //set the Server to use (Sandbox or Production)
            $serverUrl = 'https://api.ebay.com/ws/api.dll';      // server URL different for prod and sandbox
            //the token representing the eBay user to assign the call with
            $userToken = 'production user token';
        } else {
            // sandbox (test) environment
            $devID = 'sandbox dev id';   // these prod keys are different from sandbox keys
            $appID = 'sandbox app id';
            $certID = 'sandbox cert id';
            //set the Server to use (Sandbox or Production)
            $serverUrl = 'https://api.sandbox.ebay.com/ws/api.dll';
            // the token representing the eBay user to assign the call with
            // this token is a long string - don't insert new lines - different from prod token
            $userToken = 'sandbox user token';
        }
    
    
    ?>
    

    Eight
    Now we will build our first page that has some output for the user as below:

    <?php require_once('keys.php') ?>
    <?php require_once('eBaySession.php') ?>
    <?php
    
            session_start();
            //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 = 'GetSessionID';
    
            ///Build the request Xml string
            $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
            $requestXmlBody .= '<GetSessionIDRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
            $requestXmlBody .= '<RuName>'.$RuName.'</RuName>';
            $requestXmlBody .= '</GetSessionIDRequest>';
    
            //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(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue));
                //if there is a long message (ie ErrorLevel=1), display it
                if(count($longMsg) > 0)
                    echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue));
    
            }
    
            else //no errors
            {
                //get the nodes needed
                $sessionIDNode = $responseDoc->getElementsByTagName('SessionID');
                //Display the details
                $sessionID = $sessionIDNode->item(0)->nodeValue;
                $_SESSION['eBaySession'] = $sessionID;
    
            }
    ?>
    <!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</TITLE>
    </HEAD>
    <BODY>
    <FORM action="GetItem.php" method="post">
        <h2>Testing eBay Connection Plugin</h2>
        <h3>Linking User Account to our website</h3>
        <p>Session ID: <?php echo $_SESSION['eBaySession']; ?></p>
        <BR><a href="https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=<?php echo $RuName; ?>&SessID=<?php echo $sessionID; ?>">Click Here To Link Your Ebay Account To Our Website</a>
    </FORM>
    </BODY>
    </HTML>
    

    This new PHP page will receive a Session ID from eBay using $verb = 'GetSessionID'; so when we click the “Link Your Ebay Account” button the user is sent to this URL:

    https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=<?php echo $RuName; ?>&SessID=<?php echo $sessionID; ?>
    

    Which contains your RuName and Session ID.

    Ninth
    User will login to eBay, grant access to your application and sent back to your website. Now we will use the same Session ID in the previous part to receive the User Token (since we have access to the user’s account now) using $verb = 'FetchToken';.

    <?php require_once('keys.php') ?>
    <?php require_once('eBaySession.php') ?>
    <!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
    
                session_start();
                //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(">", "&gt;", str_replace("<", "&lt;", $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(">", "&gt;", str_replace("<", "&lt;", $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.'';
    
                }
        ?>
    
        </BODY>
        </HTML>
    

    And there you go you have access and a token. But make sure you host this on a HTTPS URL since eBay only accepts these function through a secure connection (SSL). Otherwise you will have difficulty running this code.

    I will improve this answer eventually by receiving feedback. I know it may confuse you a bit but I hope I could make it a better answer by time. I have also covered the GetItem function for eBay API in the question if you would need it.

    Edit: Of course you can integrate cUrl and XML requests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to mark eBay order as shipped via eBay API. Have a method:
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm new to cURL and I'm trying to access my ebay account using php
I have this function here that assembles an API call to eBay. It used
i'm new in selenium developing and i need to scrape this page: https://annunci.ebay.it/pubblica-annuncio in
I am new to eBay API .I using JSON format for request and reply.
I have some problem when i integrate PayPal with SOAP API. Now, This my
I'm creating a feedback system kind of like eBay. (Once you buy the item
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
I'm new in iOS development and I want to search eBay items with my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.