Example #1
0
 public function init()
 {
     try {
         $service = new Services\TradingService();
         $service->config(EbayConfiguration::$development);
         $request = new Types\GetOrdersRequestType();
         $request->CreateTimeFrom = new \DateTime(date('Y-m-d H:i:s', strtotime('-2 minute', strtotime($this->CreateTimeFrom))));
         $request->CreateTimeTo = new \DateTime(date('Y-m-d H:i:s', strtotime('+2 minute', strtotime($this->CreateTimeTo))));
         $request->OrderStatus = Enums\OrderStatusCodeType::C_ALL;
         $outputSelector = ['HasMoreOrders', 'OrdersPerPage', 'PageNumber', 'ReturnedOrderCountActual', 'PaginationResult.TotalNumberOfEntries', 'PaginationResult.TotalNumberOfPages', 'OrderArray.Order.OrderID', 'OrderArray.Order.OrderStatus', 'OrderArray.Order.Total', 'OrderArray.Order.Subtotal', 'OrderArray.Order.SellerUserID', 'OrderArray.Order.SellerEmail', 'OrderArray.Order.AdjustmentAmount', 'OrderArray.Order.CreatedTime', 'OrderArray.Order.ShippingAddress', 'OrderArray.Order.TransactionArray.Transaction.TransactionID', 'OrderArray.Order.TransactionArray.Transaction.Buyer.Email', 'OrderArray.Order.TransactionArray.Transaction.Item', 'OrderArray.Order.TransactionArray.Transaction.QuantityPurchased', 'OrderArray.Order.TransactionArray.Transaction.TransactionPrice'];
         if (!empty($outputSelector)) {
             $request->OutputSelector = $outputSelector;
         }
         //翻页条件
         $pagination = new Types\PaginationType();
         $pagination->EntriesPerPage = $this->entriesPerPage;
         do {
             $pagination->PageNumber = $this->pageNumber;
             $request->Pagination = $pagination;
             //请求日志
             Yii::info($request, "get_order");
             //请求ebay服务器
             $response = $service->getOrders($request);
             //返回日志
             Yii::info($response, "get_order");
             //解析返回数据,
             $this->_formartResponse($response);
             //记录执行情况
             if (isset($this->planDownload['id'])) {
                 Yii::$app->db->createCommand()->update('t_run_ebay_order_download', ['run_time' => $this->runTime, 'run_results' => $this->runResults], "id = " . $this->planDownload['id'])->execute();
             }
         } while ($this->hasNext);
         //保存ebay的返回信息
         $this->_saveResponse();
         print_r($this->orderList);
         echo "\r\n";
     } catch (\Exception $exp) {
         //写入错误日志
         Yii::error($exp, "get_order");
     }
 }
 * This determines the validation rules that eBay will apply to the request.
 * For example, it will determine what categories can be specified, the values
 * allowed as shipping services, the visibility of the item in some searches and other
 * information.
 *
 * Note that due to the risk of listing fees been raised this example will list the item
 * to the sandbox site.
 */
$siteId = Constants\SiteIds::US;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'sandbox' => true, 'siteId' => $siteId));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\AddFixedPriceItemRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];
Example #3
0
 public function getCategories()
 {
     if (EbayCategory::find()->count() > 0) {
         return true;
     }
     $service = new TradSer\TradingService(array('apiVersion' => $this->config['tradingApiVersion'], 'siteId' => Constants\SiteIds::US));
     $catconfig = $this->getCategoryConfig();
     $i = 1;
     foreach ($catconfig as $name => $cat) {
         foreach ($cat as $key => $value) {
             $request = new TradType\GetCategoriesRequestType();
             if ($i % 2 == 0) {
                 $request->CategorySiteID = '0';
             } else {
                 $request->CategorySiteID = '215';
             }
             $request->CategoryParent = array($value);
             $request->RequesterCredentials = new TradType\CustomSecurityHeaderType();
             $request->RequesterCredentials->eBayAuthToken = $this->config['production']['userToken'];
             $request->DetailLevel = array('ReturnAll');
             $request->OutputSelector = array('CategoryArray.Category.CategoryID', 'CategoryArray.Category.CategoryParentID', 'CategoryArray.Category.CategoryLevel', 'CategoryArray.Category.CategoryName');
             $cats = $service->getCategories($request)->toArray();
             $this->addCatsToDB($cats, $value);
             $i++;
         }
     }
 }
        curl_setopt($connection, CURLOPT_VERBOSE, 1);
        $response = curl_exec($connection);
        curl_close($connection);
        //return the response
        return $response;
    }
}
/**
 * Create the service object. 
 *
 * We pass in an instance of our HttpClient into the second parameter.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'siteId' => Constants\SiteIds::US), new HttpClient());
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GeteBayOfficialTimeRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['production']['userToken'];
 */
$config = (require __DIR__ . '/../configuration.php');
/**
 * The namespaces provided by the SDK.
 */
use DTS\eBaySDK\Constants;
use DTS\eBaySDK\Trading\Services;
use DTS\eBaySDK\Trading\Types;
use DTS\eBaySDK\Trading\Enums;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'sandbox' => true, 'siteId' => Constants\SiteIds::US));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\UploadSiteHostedPicturesRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];
 */
$config = (require __DIR__ . '/../configuration.php');
/**
 * The namespaces provided by the SDK.
 */
use DTS\eBaySDK\Constants;
use DTS\eBaySDK\Trading\Services;
use DTS\eBaySDK\Trading\Types;
use DTS\eBaySDK\Trading\Enums;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'siteId' => Constants\SiteIds::US));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetMyeBaySellingRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['production']['userToken'];
Example #7
0
 public function addFixedPriceListing($listingItem)
 {
     $request = new Types\AddFixedPriceItemRequestType();
     $request->RequesterCredentials = new Types\CustomSecurityHeaderType();
     $request->RequesterCredentials->eBayAuthToken = $this->token;
     //$item = new Types\ItemType();
     // bad coding
     // $item->Country = 'AU';
     // $item->Currency = 'AUD';
     // $item->ListingDuration = Enums\ListingDurationCodeType::C_GTC;
     // $item->ListingType = Enums\ListingTypeCodeType::C_FIXED_PRICE_ITEM;
     // $item->ConditionID = 1000;
     // $item->DispatchTimeMax = 1;
     // $item->ReturnPolicy = new Types\ReturnPolicyType();
     // $item->ReturnPolicy->ReturnsAcceptedOption = 'ReturnsAccepted';
     // $item->ReturnPolicy->RefundOption = 'MoneyBack';
     // $item->ReturnPolicy->ReturnsWithinOption = 'Days_14';
     // $item->ReturnPolicy->ShippingCostPaidByOption = 'Buyer';
     // $item->ShippingDetails = new Types\ShippingDetailsType();
     // $item->ShippingDetails->ShippingType = Enums\ShippingTypeCodeType::C_FLAT;
     //
     // $item->Quantity = (int)$listingItem->qty;
     // $item->StartPrice = new Types\AmountType(array('value' => (double)$listingItem->price));;
     // $item->BestOfferDetails = new Types\BestOfferDetailsType();
     // //return var_dump($listingItem->bestOffer);
     // if($listingItem->bestOffer!="false"){
     // 	$item->BestOfferDetails->BestOfferEnabled = true;
     // 	$item->ListingDetails = new Types\ListingDetailsType();
     // 	$item->ListingDetails->BestOfferAutoAcceptPrice = new Types\AmountType(array('value' => (double)$listingItem->bestOffer[0]));
     // 	$item->ListingDetails->MinimumBestOfferPrice = new Types\AmountType(array('value' => (double)$listingItem->bestOffer[1]));
     // }else{
     // 	$item->BestOfferDetails->BestOfferEnabled = false;
     // }
     //
     // $item->PrimaryCategory = new Types\CategoryType();
     // $item->PrimaryCategory->CategoryID = $listingItem->primaryCate;
     // $item->Title = $listingItem->title;
     // $item->Description = "<![CDATA[" . $listingItem->description . "]]>";
     // //$item->Description = "test";
     // $item->SKU = $listingItem->sku;
     // $item->Location = $listingItem->location;
     // $item->PictureDetails = new Types\PictureDetailsType();
     // $item->PictureDetails->GalleryType = Enums\GalleryTypeCodeType::C_GALLERY;
     // $item->PictureDetails->PictureURL = $listingItem->picture;
     // $item->PaymentMethods = array(
     //     'PayPal'
     // );
     // $item->PayPalEmailAddress = $listingItem->paypal;
     // $shippingService = new Types\ShippingServiceOptionsType();
     // $shippingService->ShippingServicePriority = 1;
     // $shippingService->ShippingService = $listingItem->shippingService;
     // if($listingItem->shippingCost=="true"){
     // 	$shippingService->FreeShipping = true;
     // }else{
     // 	$shippingService->ShippingServiceCost = new Types\AmountType(array('value' => (double)$listingItem->shippingCost[0]));
     // 	$shippingService->ShippingServiceAdditionalCost = new Types\AmountType(array('value' => (double)$listingItem->shippingCost[1]));
     // }
     //
     // $item->ShippingDetails->ShippingServiceOptions[] = $shippingService;
     $item = $this->buildItem($listingItem);
     $request->Item = $item;
     //$service = $this->tradingServiceInit();
     $service = new Services\TradingService(array('apiVersion' => EbayApi::COMPATABILITY_LEVEL, 'siteId' => EbayApi::SITE_ID, 'authToken' => $this->token, 'devId' => EbayApi::DEV_ID, 'appId' => EbayApi::APP_ID, 'certId' => EbayApi::CERT_ID));
     $result['itemID'] = "123";
     //$result['error'][] = "123";
     //$result['error'][] = "fail";
     return $result;
     $response = $service->addFixedPriceItem($request);
     $result = [];
     if (isset($response->Errors)) {
         foreach ($response->Errors as $error) {
             $result['error'][] = $error->ShortMessage;
             $result['error'][] = $error->LongMessage;
         }
     }
     if ($response->Ack !== 'Failure') {
         $result['itemID'] = $response->ItemID;
     }
     return $result;
 }
 /**
  * @return mixed
  */
 public function getConfig()
 {
     return $this->service->config();
 }
<?php

require 'api_eby/ebay-sdk-php-autoloader.php';
use DTS\eBaySDK\Constants;
use DTS\eBaySDK\Trading\Services;
use DTS\eBaySDK\Trading\Types;
use DTS\eBaySDK\Trading\Enums;
$service = new Services\TradingService(array('appId' => 'CGM968b04-70b4-43d7-a7db-ff8903ad23b', 'apiVersion' => '871', 'sandbox' => 'true', 'siteId' => Constants\SiteIds::US));
$request = new Types\GetStoreRequestType();
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = 'AgAAAA**AQAAAA**aAAAAA**5SeqVg**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhDpaLog2dj6x9nY+seQ**ObADAA**AAMAAA**mvKNWcyEW52daMrRGUF/S91xn4Sk+gI//sMCTEStI4H+rj5ZH+ZG0i/LRnuqozz0tlHwGtsM5XKTgZ/1HVZqsaAlx1b1nKYs505sYP0qchX2oHovuFgGHJCcCiwtfJxd7G1k+u8reg8ttrGov2aZgF+yCNZL7kNxxZVBAFXWJqZyQyZDUMZMGV7JfEOW/xCSZG14ZQJhYat5QATzNLLTKTloSwd+0MS7oUPwhR8XTtY+2YRLeHL5JpuILxUSyUacHMfe8kS8tNP5sbMrEjxsG9gO4EuJDISvtDapU8jiYg3BFI0hvBfwI6sMK01QXRQIYxvrhgHKq79suV8CslMWu8UFyZ6jBTRBPkYVfqzoj81mAORewhgx14vbRN9Hmu3SzJZzc+R5BxHgpbbw4MDndIVj6nM+A/yB/K7jM//6YK3JfhkPWYmNQZijpL5cZ+x7bBLOBZLKl6cmiLoiEnJQE3acaZCxm9JD9B0DOm+Q3ImoItx1+g1VBU62waxFkWO5fAl9sV+riGSWdNDAzFtGPs3qAFoogzPGkLHn2lNemWmwxggZK+YTy5mqgtSsRFLt2Ao50aTW4oQWsapFJDQhsJw8NeWjRsbGJqLWts5eZMT3Xre51d+Hb+qYUO27VoFHMgmm3CYxD+WsXe6iRvSCJSm0S9WyX5i88VQw7fO7hPoZ90vbVtALyqNkt+fdf2NpAiunIZ5TXbuZz2auMHUqNSS1M2bjEBEeayq6HVSWvcnHBoHiRchATIkmHFo2nCfL';
$response = $service->getStore($request);
if (isset($response->Errors)) {
    foreach ($response->Errors as $error) {
        printf("%s: %s\n%s\n\n", $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', $error->ShortMessage, $error->LongMessage);
    }
}
if ($response->Ack !== 'Failure') {
    $store = $response->Store;
    printf("Name: %s\nDescription: %s\nURL: %s\n\n", $store->Name, $store->Description, $store->URL);
    foreach ($store->CustomCategories->CustomCategory as $category) {
        printCategory($category, 0);
    }
}
function printCategory($category, $level)
{
    printf("%s%s : (%s)\n", str_pad('', $level * 4), $category->Name, $category->CategoryID);
    foreach ($category->ChildCategory as $category) {
        printCategory($category, $level + 1);
    }
}
 * This determines the validation rules that eBay will apply to the request.
 * For example, it will determine what categories can be specified, the values
 * allowed as shipping services, the visibility of the item in some searches and other
 * information.
 *
 * Note that due to the risk of listing fees been raised this example will list the item
 * to the sandbox site.
 */
$siteId = Constants\SiteIds::US;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'sandbox' => true, 'siteId' => $siteId));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\AddItemRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];
 * http://devbay.net/sdk/guides/application-keys/
 */
$config = (require __DIR__ . '/../configuration.php');
/**
 * The namespaces provided by the SDK.
 */
use DTS\eBaySDK\Constants;
use DTS\eBaySDK\Trading\Services;
use DTS\eBaySDK\Trading\Types;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'siteId' => Constants\SiteIds::US));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetCategoriesRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['production']['userToken'];
 *
 * For more information, see:
 * http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetCategorySpecifics.html#downloadFile
 */
/**
 * Specify the numerical site id that we to download the category specifics for.
 * Note that each site will have its own category structure and specifics.
 */
$siteId = Constants\SiteIds::US;
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Trading\Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'siteId' => $siteId));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Trading\Types\GetCategorySpecificsRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */
$request->RequesterCredentials = new Trading\Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['production']['userToken'];
Example #13
0
global $user, $service, $token;
$config = array('sandbox' => array('devId' => $user['dev_name'], 'appId' => $user['app_name'], 'certId' => $user['cert_name'], 'userToken' => $token), 'production' => array('devId' => $user['dev_name'], 'appId' => $user['app_name'], 'certId' => $user['cert_name'], 'userToken' => $token), 'findingApiVersion' => '1.12.0', 'tradingApiVersion' => '871', 'shoppingApiVersion' => '871', 'halfFindingApiVersion' => '1.2.0');
/**
 * The namespaces provided by the SDK.
 */
use DTS\eBaySDK\Constants;
use DTS\eBaySDK\Trading\Services;
use DTS\eBaySDK\Trading\Enums;
define('DEBUG', true);
/**
 * Create the service object.
 *
 * For more information about creating a service object, see:
 * http://devbay.net/sdk/guides/getting-started/#service-object
 */
$service = new Services\TradingService(array('apiVersion' => $config['tradingApiVersion'], 'sandbox' => $user['sandbox'] == 1, 'siteId' => Constants\SiteIds::US, 'devId' => $user['dev_name'], 'appId' => $user['app_name'], 'certId' => $user['cert_name'], 'debug' => DEBUG));
if (DEBUG) {
    $logger = new \DTS\eBaySDK\Mocks\Logger();
    $service->logger($logger);
}
function show_log()
{
    global $logger;
    xp($logger);
}
function show_response_errors($response)
{
    if (isset($response->Errors)) {
        foreach ($response->Errors as $error) {
            printf("%s: %s\n%s\n\n", $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', $error->ShortMessage, $error->LongMessage);
        }