Giter Site home page Giter Site logo

ebay's Introduction

Ebay

A simple Ebay class that uses OAuth 2.0 Authentication and PSR-16 cache

Basic usage: First initialize the EbayRequest. I use Redis for cache driver.

<?php

use Phpfastcache\Helper\Psr16Adapter;
use BrainStorm\Ebay\EbayRequest;

$args = [
	'env' => 'production',	//use sandbox for test
	'devId' => '',	//devID param from Ebay
	'appId' => '',	//appID param from Ebay
	'certId' => '',	//certID param from Ebay
	'RuName' => '',	//RuName param from Ebay
	'version' => '967',	//Ebay API Version
	'siteid' => '0',	//SiteID (See Ebay for other SiteID)
	'scope' => 'https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/buy.order.readonly https://api.ebay.com/oauth/api_scope/buy.guest.order https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly https://api.ebay.com/oauth/api_scope/commerce.catalog.readonly https://api.ebay.com/oauth/api_scope/buy.shopping.cart https://api.ebay.com/oauth/api_scope/buy.offer.auction https://api.ebay.com/oauth/api_scope/commerce.identity.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.email.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.phone.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.address.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.name.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.status.readonly https://api.ebay.com/oauth/api_scope/sell.finances https://api.ebay.com/oauth/api_scope/sell.item.draft https://api.ebay.com/oauth/api_scope/sell.payment.dispute https://api.ebay.com/oauth/api_scope/sell.item https://api.ebay.com/oauth/api_scope/sell.reputation https://api.ebay.com/oauth/api_scope/sell.reputation.readonly'
];

$Psr16Adapter = new Psr16Adapter('Redis');
$client = new EbayRequest($args, $Psr16Adapter);

/**
* Do your stuff with $data
*/

After, you need an user account to generate token to access API. The user must click to the link generated by:

echo $client->getUrlUserConsent();

You must configure a return URL in your Ebay application (from Ebay panel) that point to a route that cointains this code:

$usercode = $_GET['code'];
$expire = $_GET['expires_in'];
$refresh_token = $client->setAuthToken($usercode, $expire);

/**
* Store $refresh_token into DB
*/

You must save the $refresh_token into a safe place (DB preferred). It will be used to generate a new user token for every API call (after user token expire). This operations are needed to generate the refresh token (if not exists or is expired). With the refresh token, you can call the Ebay API that you need:

<?php

use Phpfastcache\Helper\Psr16Adapter;
use BrainStorm\Ebay\EbayRequest;
use BrainStorm\Ebay\Trading\GetCategories;

$args = [
	'env' => 'production',	//use sandbox for test
	'devId' => '',	//devID param from Ebay
	'appId' => '',	//appID param from Ebay
	'certId' => '',	//certID param from Ebay
	'RuName' => '',	//RuName param from Ebay
	'version' => '967',	//Ebay API Version
	'siteid' => '0',	//SiteID (See Ebay for other SiteID)
	'scope' => 'https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/buy.order.readonly https://api.ebay.com/oauth/api_scope/buy.guest.order https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly https://api.ebay.com/oauth/api_scope/commerce.catalog.readonly https://api.ebay.com/oauth/api_scope/buy.shopping.cart https://api.ebay.com/oauth/api_scope/buy.offer.auction https://api.ebay.com/oauth/api_scope/commerce.identity.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.email.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.phone.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.address.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.name.readonly https://api.ebay.com/oauth/api_scope/commerce.identity.status.readonly https://api.ebay.com/oauth/api_scope/sell.finances https://api.ebay.com/oauth/api_scope/sell.item.draft https://api.ebay.com/oauth/api_scope/sell.payment.dispute https://api.ebay.com/oauth/api_scope/sell.item https://api.ebay.com/oauth/api_scope/sell.reputation https://api.ebay.com/oauth/api_scope/sell.reputation.readonly'
];
$Psr16Adapter = new Psr16Adapter('Redis');
$client = new EbayRequest($args, $Psr16Adapter);
$trading = new GetCategories($client);
echo $trading->doRequest($refresh_token);

ebay's People

Contributors

brainstormdevel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.