我想在perl / c ++中创建一个脚本,它会在ebay上将我的数量在凌晨4点变为0,每天在下午1点变为5,这应该会自动发生。我发现我能够通过脚本连接到我的ebay帐户,但无法编辑数量。
我在这部分遇到语法错误。我使用过ReviseInventoryStatusRequest
# define the HTTP header
my $objHeader = HTTP::Headers->new;
$objHeader->push_header('X-EBAY-API-COMPATIBILITY-LEVEL' => '391');
$objHeader->push_header('X-EBAY-API-DEV-NAME' => 'dev id to be given here');
$objHeader->push_header('X-EBAY-API-APP-NAME' => 'app id to be given here');
$objHeader->push_header('X-EBAY-API-CERT-NAME' => 'cert id to be given here');
$objHeader->push_header('X-EBAY-API-CALL-NAME' => 'GeteBayOfficialTime');
$objHeader->push_header('X-EBAY-API-SITEID' => '0');
$objHeader->push_header('Content-Type' => 'text/xml');
# define the XML request
my $request =
"<?xml version='1.0' encoding='utf-8'?>" .
"<GeteBayOfficialTimeRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" .
" <RequesterCredentials>" .
" <eBayAuthToken>my token here
</eBayAuthToken>" .
" </RequesterCredentials>" .
"</GeteBayOfficialTimeRequest>";
my $inventory=
"<?xml version='1.0' encoding='utf-8'?>" .
"<ReviseInventoryStatusRequest xmlns="urn:ebay:apis:eBLBaseComponents">" .
"<RequesterCredentials>" .
" <eBayAuthToken>My token here
</eBayAuthToken>" .
" <InventoryStatus>" .
" <ItemID>262906308587</ItemID>" .
"<Quantity>0</Quantity>" .
"</InventoryStatus>" .
"</ReviseInventoryStatusRequest>";
# make the call
my $objRequest = HTTP::Request->new(
"POST",
"https://api.sandbox.ebay.com/ws/api.dll",
$objHeader,
$request,
$inventory
);
# deal with the response
my $objUserAgent = LWP::UserAgent->new;
my $objResponse = $objUserAgent->request($objRequest);
if (!$objResponse->is_error) {
print $objResponse->content;
}
else {
print $objResponse->error_as_HTML;
}
如果有人可以建议如何编辑此代码或任何其他可用于实现此目的的代码,那么会很棒。感谢
答案 0 :(得分:1)
eBay不允许在 eBay SendBox帐户中设置0个数量。
在eBay Production帐户中,您可以设置0数量,产品将不会显示给客户。如果您通过item-id搜索产品,那么您可以看到产品状态为缺货。
在eBay Production帐户中, OUT Of Stock 产品有一种配置。
您可以通过手动配置或API进行操作。
转到易趣卖家帐户&gt;&gt; SetUserPreferences &gt;&gt;设置 OutOfStockControlPreference True。
eBay也提供API SetUserPreferences 。
<?xml version="1.0" encoding="utf-8"?>
<SetUserPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>ABC...123</eBayAuthToken>
</RequesterCredentials>
<WarningLevel>High</WarningLevel>
<SellerPaymentPreferences>
<OutOfStockControlPreference>true</OutOfStockControlPreference>
</SellerPaymentPreferences>
</SetUserPreferencesRequest>
如果在eBay生产帐户 OutOfStockControlPreference 为False,那么您也不允许在eBay中更新0股票。
您可以使用以下链接推荐易趣API。
http://developer.ebay.com/devzone/xml/docs/Reference/eBay/SetUserPreferences.html#Samples