shopapi/ebay-api

使用 eBay API 访问 eBay 平台上的搜索功能

0.2 2015-04-24 00:26 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:49:01 UTC


README

使用 eBay API 访问 eBay 平台上的搜索功能

安装包

步骤 1:使用 composer 下载 EbayApiBundle

在 composer.json 中添加 EbayApiBundle
`{
    "require": {
        "shopapi/ebay-api": "~0.1"
    }
}`

步骤 2:启用包

在 kernel 中启用包

<?php
// app/AppKernel.php
  
public function registerBundles()
{
  $bundles = array(
      // ...
      new Myw\EbayApiBundle\MywEbayApiBundle(),
  );
}

步骤 3:配置

app/config/config.yml

myw_ebay_api

auth_token: %token_api_ebay%
sandbox:
    dev_id: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    app_name: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
    cert_name: xxxxxxxx-xxxx-xxxx-xxx-xxxxxxxxxxxx
production:
    dev_id: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    app_name: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
    cert_name: xxxxxxxx-xxxx-xxxx-xxx-xxxxxxxxxxxx

parameter.yml

token_api_ebay: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

步骤 4:在控制器中调用服务

示例:Trading API 中的 getCategories 方法

<?php
  
    $ebayManager = $this->get('myw_ebay_api_manager');
    $component = $ebayManager->getManager('Trading', 'getCategories', EbayApiManager::MODE_SANDBOX);
    // setCategoryParent identifying a category that is an ancestor of the category indicated in CategoryID. 
	$component->setCategoryParent(267);
	// eBay site to which you want to send the request. See http://developer.ebay.com/Devzone/XML/docs/Reference/ebay/types/SiteCodeType.html for a list of valid site ID values. 
	$component->setCategorySiteID(0);
	
	//The level where the category fits in the site's category hierarchy. For example, if this field has a value of 2, then the category is 2 levels below the root category.
	$component->setLevelLimit(2);
	
	/*
	* Detail levels are instructions that define standard subsets of data to return for particular data components (e.g., each Item, Transaction, or User) 
	* within the response payload.
	* Applicable Values: see http://developer.ebay.com/devzone/xml/docs/reference/ebay/types/DetailLevelCodeType.html
	*/
	$component->setDetailLevel('ReturnAll');
	
	/*
	* Use ErrorLanguage to return error strings for the call in a different language from the language commonly associated with the site that the requesting user is registered with. 
	* Specify the standard RFC 3066 language identification tag (e.g., en_US). 
	* en_GB 	United Kingdom
	* en_US 	United States
	* de_DE 	Germany
	*/
	$component->setErrorLanguage("en_EN");
	
	/*
	* You can use the OutputSelector field to restrict the data returned by a call.
	* Example: Restricting a GetItem Response to ViewItemURL
	* $component->setOutputSelector("ViewItemURL");
	* more details see http://developer.ebay.com/DevZone/guides/ebayfeatures/Basics/eBay-SelectingFields.html
	*/
	$component->setOutputSelector("ViewItemURL");
	
	//Get Call service
	$ebayCall = $this->get('myw_ebay_api_call');
	
	// Get response. The response is array
	$response = $ebayCall->getResponse($component);