Code Monkey home page Code Monkey logo

ebay-java-sdk's Introduction

ebay-java-sdk

Version 1131

This is a clone of the official eBay Java SDK, but structured as a Maven project for easy installation and use in Java applications. The SDK provides a simple Java API for calling eBay's Trading API.

Javadocs for the latest official distribution of the SDK can be found here.

The release notes for version 1131 of the Trading API can be found here

Usage

Note: You need an eBay Developer Account to use this SDK.

You must build and install the eBay Java SDK before including it as a dependency in your application. Included in this repository is the Maven Wrapper which you can use if you don't have Maven already installed.

Building and Installing the eBay Java SDK

It's recommended to compile this with JDK 8, although JDK 7 will probably work too.

  1. Clone this repository:

    git clone https://github.com/ethanrubinson/ebay-java-sdk
  2. Navigate to the project root:

    cd ebay-java-sdk/
  3. Use Maven, or the Maven Wrapper to build and install the SDK:

    # Use an existing Maven installation
    mvn clean install
    
    # Use the Maven Wrapper on Unix
    ./mvnw clean install
    
    # Use the Maven Wrapper for Batch
    ./mvnw.cmd clean install
  4. Check your console for successful build and installation logs. It should look similar to this:

    [INFO] Installing .../ebay-java-sdk/target/ebaysdkcore-1131.jar to .../ebaysdkcore/ebaysdkcore/1131/ebaysdkcore-1131.jar
    [INFO] Installing .../ebay-java-sdk/pom.xml to .../ebaysdkcore/ebaysdkcore/1131/ebaysdkcore-1131.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  ...
    [INFO] Finished at: ...
    [INFO] ------------------------------------------------------------------------
    

Congratulations! The eBay Java SDK is now installed in your local repository and ready to be included in your projects.

Including the Installed eBay Java SDK in Maven Projects

To include the now-installed SDK in your Maven project, simply add the following dependency in your pom.xml file:

<dependency>
  <groupId>ebaysdkcore</groupId>
  <artifactId>ebaysdkcore</artifactId>
  <version>1131</version>
</dependency>

Including the Installed eBay Java SDK in Java Projects

The eBay Java SDK can also be included in regular Java Projects by configuring your build path.

Option 1) Add the SDK as a project dependency

In Eclipse (or your desired IDE), Go to File > Import... and select Maven > Existing Maven Projects as the import source. Browse to the root of the ebay-java-sdk folder and import the project.

Next, in your project, look for a setting called Configure Build Path... or Java Build Path. Add the ebaysdkcore project under the 'Projects' tab in the build path settings.

Option 2) Add the SDK JAR as a library dependency

Look for a setting called Configure Build Path... or Java Build Path. Under the 'Libraries' tab in the build path settings click Add External JARs.

Add the ebaysdkcore-1131.jar which was installed to your Maven local repository. The location of this JAR can be found in the build output above:

[INFO] Installing .../ebay-java-sdk/target/ebaysdkcore-1131.jar to ...

Making an API Call

The following code shows the bare minimum implementation needed to call eBay's Trading API. It gets the current eBay time on the US site and prints it out to the console.

import java.util.Calendar;

import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.call.GeteBayOfficialTimeCall;
import com.ebay.sdk.helper.ConsoleUtil;

public class ApplicationHelloWorld {

  public static void main(String[] args) {
    try {
      /*
       * Step 1) Instantiate a new instance of ApiContext
       */
      ApiContext apiContext = new ApiContext();

      /*
       * Step 2) Get the ApiCredential instance from the ApiContext you just created.
       */
      ApiCredential cred = apiContext.getApiCredential();

      /* 
       * Step 3) Configure ONE of the following authentication strategies:
       * 
       * a) Use an OAuth user-token. This token can be minted from the ebay-oauth-java-client. [RECOMMENDED]
       * --> cred.setOAuthToken(oAuthToken);
       * 
       * b) Use an eBay (Auth'n'Auth) user-token. [NOT RECOMMENDED]
       * --> cred.seteBayToken(oAuthToken);
       * 
       * c) Use your eBay Developer Account and eBay Account credentials directly. [NOT RECOMMENDED]
       * --> cred.setApiAccount(apiAccount);
       * --> cred.seteBayAccount(ebayAccount);
       */
      String oAuthUserToken = ConsoleUtil.readString("Enter your eBay Authentication Token: ");
      cred.setOAuthToken(oAuthUserToken);

      /*
       * Step 4) Set API server URL for the environment you'll be calling.
       * 
       *  Production --> https://api.ebay.com/wsapi
       *  Sandbox    --> https://api.sandbox.ebay.com/wsapi
       */
      String apiUrl = ConsoleUtil.readString("Enter eBay SOAP server URL (e.g., https://api.ebay.com/wsapi): ");
      apiContext.setApiServerUrl(apiUrl);

      /*
       * Step 5) Create a call object with the ApiContext instance you've configured and execute it.
       */
      GeteBayOfficialTimeCall apiCall = new GeteBayOfficialTimeCall(apiContext);
      Calendar cal = apiCall.geteBayOfficialTime();

      System.out.println("Official eBay Time : " + cal.getTime().toString());
    } catch (Exception e) {
      System.out.println("Failed to get the eBay official time.");
      e.printStackTrace();
    }

  }

}

ebay-java-sdk's People

Contributors

ethanrubinson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ebay-java-sdk's Issues

package com.ebay.soap.eBLBaseComponents does not exist

Hello,

First, thanks for your job, but I have an issue.

When I open the project, my Eclipse said me in the pom.xml :
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: default, phase: generate-sources)

So I fixed that adding <pluginManagement> tag to the pom.xml : Stack Overflow

But now I still have a problem.
Eclipse doesn't seems found the wsimport dependency because every object from com.ebay.soap.eBLBaseComponents are marked as cannot be resolved to a type.

Same problem with maven install/compile, every objects are marked as package com.ebay.soap.eBLBaseComponents does not exist...

Thanks for your help
Yani :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.