Skip to content

PHP class encapsulates uploadFile, getTask, OAuth user tokens, and more using the new Feed API that replaces FileExchange

License

Notifications You must be signed in to change notification settings

rickapps/eBay-Sell-Feed-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eBay-Sell-Feed-API

Demonstrates how to upload a file to eBay and get the results using eBay's new Sell Feed API replacement for FileExchange.

To use this code in your PHP project, you only need two files:

application/libs/eBayRepository.php
application/conf/PHPConstants.php

<?php
$eBayRep = new eBayRepository(YourAuthorizationCode, YourRefreshToken);
$taskID = $eBayRep->sendToEbay('FileYouWantToUpload');
$json = $eBayRep->getResults($taskID);
?>

It can take some time for eBay to process your upload file, so you might want to call the last line above, getResults($taskID), repeatedly. These four eBay API calls are utilized by the repository class: createTask, uploadFile, getTask, and OAuth2/token

Notes

Many csv files that work fine on eBay's production environment will be marked 'Failed' in the sandbox environment. Don't waste time trying to debug import file structure in the sandbox. Make use of the action VerifyAdd to avoid accruing listing fees in the production environment.

eBay does not list csv files marked 'Failed' on the Upload History page in My eBay.

eBay API will often mark a file that contains an invalid category id as 'Failed' and offer no error message to explain why.

eBay's API documentation for uploadFile says to use option 'fileName' to specify the file you want to upload. This always gave me errors. I changed the option to 'file' and it started working.

In the production environment, you will get timed out if you make too many createTask calls in a short time period. If this happens, wait one hour before trying again. The timeout does not seem to apply to the sandbox environment.

Use Postman to help with debugging API calls. It will make your work much easier. It provides more helpful options than the API Explorer in eBay Developer tools.

Installation

To run the website:

  1. Install curl on your webserver if not already installed.
  2. Ensure the project folder /public_html is browsable on your webserver.
  3. Set permissions on /public_html/export so your webserver can write to it.
  4. Set permissions in php.ini so the application can upload files.
  5. Edit the file PHPConstants. You only need to generate an authorization code once. Instructions can be found here. You will need to generate a refresh token about every 18 months. Instructions can be found here. Your values are specific to the eBay sandbox and the eBay production environments.

Screenshot 1 Screenshot 2 Screenshot 3

About

PHP class encapsulates uploadFile, getTask, OAuth user tokens, and more using the new Feed API that replaces FileExchange

Topics

Resources

License

Stars

Watchers

Forks