无法使用 eBay API 创建立即购买列表而不是拍卖


Unable to create buy it now listing instead of auction using eBay API

我正在使用eBay API中的以下代码在eBay中创建新列表。

但是,该代码仅创建auction类型的列表。我尝试不设置起始价格,只添加了立即购买价格,但结果仍然是auction列表。

如何创建buy it now商品/商品?

这是我调用 API AddItem端点的 PHP 代码:

<?php
/********************************************
addItem.php
Uses eBay Trading API to list an item under
a seller's account.
********************************************/
// include our Trading API constants
require_once 'tradingConstants.php';
// check if posted
if (!empty($_POST)) {
// grab our posted keywords and call helper function
// TODO: check if need urlencode
$title = $_POST['title'];
$categoryID = $_POST['categoryID'];
$startPrice = $_POST['startPrice'];
$pictureURL = $_POST['pictureURL'];
$description = $_POST['description'];
// call the getAddItem function to make AddItem call
  $response = getAddItem($title, $categoryID, $startPrice, $pictureURL, $description);
}
// Function to call the Trading API AddItem
function getAddItem($addTitle, $addCatID, $addSPrice, $addPicture, $addDesc) {
/* Sample XML Request Block for minimum AddItem request
see ... for sample XML block given length*/
// Create unique id for adding item to prevent duplicate adds
$uuid = md5(uniqid());
// create the XML request
$xmlRequest = "<?xml version='"1.0'" encoding='"utf-8'"?>";
$xmlRequest .= "<AddItemRequest xmlns='"urn:ebay:apis:eBLBaseComponents'">";
$xmlRequest .= "<ErrorLanguage>en_US</ErrorLanguage>";
  $xmlRequest .= "<WarningLevel>High</WarningLevel>";
  $xmlRequest .= "<Item>";
  $xmlRequest .= "<Title>" . $addTitle . "</Title>";
  $xmlRequest .= "<Description>" . $addDesc . "</Description>";
  $xmlRequest .= "<PrimaryCategory>";
  $xmlRequest .= "<CategoryID>" . $addCatID . "</CategoryID>";
  $xmlRequest .= "</PrimaryCategory>";
  $xmlRequest .= "<StartPrice>" . $addSPrice . "</StartPrice>";
  $xmlRequest .= "<ConditionID>1000</ConditionID>";
  $xmlRequest .= "<CategoryMappingAllowed>true</CategoryMappingAllowed>";
  $xmlRequest .= "<BuyItNowPrice currencyID='"USD'">" . $addSPrice . "</BuyItNowPrice>";
  $xmlRequest .= "<Country>US</Country>";
  $xmlRequest .= "<Currency>USD</Currency>";
  $xmlRequest .= "<DispatchTimeMax>3</DispatchTimeMax>";
  $xmlRequest .= "<ListingDuration>Days_7</ListingDuration>";
  $xmlRequest .= "<ListingType>FixedPriceItem</ListingType>";
  $xmlRequest .= "<PaymentMethods>PayPal</PaymentMethods>";
  $xmlRequest .= "<PayPalEmailAddress>@gmail.com</PayPalEmailAddress>";
  $xmlRequest .= "<PictureDetails>";
  $xmlRequest .= "<PictureURL>" . $addPicture . "</PictureURL>";
  $xmlRequest .= "</PictureDetails>";
  $xmlRequest .= "<PostalCode>05485</PostalCode>";
  $xmlRequest .= "<Quantity>1</Quantity>";
  $xmlRequest .= "<ReturnPolicy>";
  $xmlRequest .= "<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>";
  $xmlRequest .= "<RefundOption>MoneyBack</RefundOption>";
  $xmlRequest .= "<ReturnsWithinOption>Days_30</ReturnsWithinOption>";
  $xmlRequest .= "<Description>" . $addDesc . "</Description>";
  $xmlRequest .= "<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>";
  $xmlRequest .= "</ReturnPolicy>";
  $xmlRequest .= "<ShippingDetails>";
  $xmlRequest .= "<ShippingType>Flat</ShippingType>";
  $xmlRequest .= "<ShippingServiceOptions>";
$xmlRequest .= "<ShippingServicePriority>1</ShippingServicePriority>";
  $xmlRequest .= "<ShippingService>USPSMedia</ShippingService>";
  $xmlRequest .= "<ShippingServiceCost>2.50</ShippingServiceCost>";
  $xmlRequest .= "</ShippingServiceOptions>";
  $xmlRequest .= "</ShippingDetails>";
  $xmlRequest .= "<Site>US</Site>";
  $xmlRequest .= "<UUID>" . $uuid . "</UUID>";
  $xmlRequest .= "</Item>";
  $xmlRequest .= "<RequesterCredentials>";
  $xmlRequest .= "<eBayAuthToken>" . AUTH_TOKEN . "</eBayAuthToken>";
  $xmlRequest .= "</RequesterCredentials>";
  $xmlRequest .= "<WarningLevel>High</WarningLevel>";
$xmlRequest .= "</AddItemRequest>";
// define our header array for the Trading API call
// notice different headers from shopping API and SITE_ID changes to SITEID
$headers = array(
'X-EBAY-API-SITEID:'.SITEID,
'X-EBAY-API-CALL-NAME:AddItem',
'X-EBAY-API-REQUEST-ENCODING:'.RESPONSE_ENCODING,
'X-EBAY-API-COMPATIBILITY-LEVEL:' . API_COMPATIBILITY_LEVEL,
'X-EBAY-API-DEV-NAME:' . API_DEV_NAME,
'X-EBAY-API-APP-NAME:' . API_APP_NAME,
'X-EBAY-API-CERT-NAME:' . API_CERT_NAME,
'Content-Type: text/xml;charset=utf-8'
);
// initialize our curl session
$session = curl_init(API_URL);
// set our curl options with the XML request
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// execute the curl request
$responseXML = curl_exec($session);
// close the curl session
curl_close($session);
// return the response XML
return $responseXML;
}
?>

这是因为您使用了错误的API调用,如果您想创建立即购买(仅)项目,则应使用"AddFixedPriceItem"调用

你可以在这里尝试这个调用:https://ebay-sdk.intradesys.com/s/b53b3a3d6ab90ce0268229151c9bde11 它应该使用你已经拥有的几乎相同的输入。

如果您想使用"立即购买"选项创建拍卖物品,您可以继续调用addItem,但您需要在ItemObject中添加"BuyItNowPrice"对象