perl - 无法使用 eBay API 更新列表的描述
问题描述
我正在尝试编写一个Perl脚本,该脚本将更新我们的eBay 列表描述,而无需继续登录(如果证明很难保持库存水平、描述等更新,则跨多个市场运行)。这是我到目前为止所拥有的:
my $ebay = new Net::eBay( {
SiteLevel => 'prod',
DeveloperKey => 'x',
ApplicationKey => 'x',
CertificateKey => 'x',
Token => 'x',
} );
$ebay->setDefaults( { API => 2, compatibility => 900 } );
my $new_desc = q|<meta name="viewport" content="width=device-width, initial-scale=1.0">
<p>We are proud to announce our first ever badge! With an easy-to-iron
on backing, fitting couldn't be any easier! We have designed the path to
be a perfect addition to any piece of cosplay costume. Please do send
in the photos of it being used on your costumes, as we would love to
share.</p>
<p>The badge is 7 x 7 cm / 2 x 2 inches in size, and 2mm thi<br></p>|;
my $result = $ebay->submitRequest( "ReviseItem",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
Item => {
Description => \$new_desc,
ItemID => 253430606975
},
ItemID => 253430606975
}) || die;
print "Result: " . Dumper( $result ) . "\n";
运行它时出现错误:
'Errors' => [
{
'ShortMessage' => 'Return Policy Attribute Not Valid',
'ErrorClassification' => 'RequestError',
'ErrorCode' => '21920200',
'LongMessage' => 'Return Policy Attribute returnDescription Not Valid On This Site',
'SeverityCode' => 'Warning',
'ErrorParameters' => {
'Value' => 'returnDescription',
'ParamID' => '0'
}
},
{
'ShortMessage' => 'Description is missing.',
'ErrorClassification' => 'RequestError',
'ErrorCode' => '106',
'SeverityCode' => 'Error',
'LongMessage' => 'A description is required.'
}
],
我是否误解了传入的内容?据我了解,您只需传入要更改的参数?
更新:正如 Dave 所建议的,我正在给Marketplace::Ebay 试一试。只是通过尝试选择我的一项来进行测试:
my $ebay = Marketplace::Ebay->new(
production => 1,
site_id => 3,
developer_key => 'xx',
application_key => 'xx',
certificate_key => 'xxx',
token => 'xx',
xsd_file => 'ebaySvc.xsd',
);
my $res = $ebay->api_call('GetItem', { ItemID => 253430606975 });
print Dumper($res);
但我得到一些奇怪的错误:
错误:元素 `{urn:ebay:apis:eBLBaseComponents}GiftIcon' 未处理 {urn:ebay:apis:eBLBaseComponents}GetItemResponse/Item at // [ 5]/*[6] $VAR1 = undef;
有任何想法吗?
解决方案
啊哈——明白了!问题似乎与传递 HTML 的方式有关。如果我把它放在一个CDATA
标签里,它工作正常:
my $new_desc = q|<![CDATA[
some html etc here
]]>|;
my $result = $ebay->submitRequest( "ReviseItem",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
Item => {
Description => $new_desc,
ItemID => 253430606975
},
ItemID => 253430606975
}) || die;
...并完美更新
推荐阅读
- bpmn - Camunda - 中间消息事件不能与单个执行相关联
- django - 自定义模板中的 Django 管理过滤器
- android - 安卓 back4app。如何回滚或何时是提交点(事务控制)
- sql - 为什么我会收到大量重复记录?
- python - 在 Python 中模糊查找扑克翻牌
- jquery - jQuery 中的 Ajax - 无意循环
- node.js - 在 Strapi 的内容类型中添加组字段时出现“TypeError:无法读取未定义的属性 '0'”
- excel - VBA 新手,在两个不同的电子表格中为每个位置分配指定数量的建筑物
- go - 下面的两个 go 代码有什么区别,为什么使用如此不同的内存
- c - 为什么我的 (Leetcode #231) Power of Two 的实现会给出错误的结果?