gpt4 book ai didi

php - 当项目名称包含&符号时,eBay API PHP 和 XML 解析错误

转载 作者:可可西里 更新时间:2023-11-01 01:02:35 25 4
gpt4 key购买 nike

我一直在测试我的 PHP 应用程序,以使用他们的交易 API 在 eBay 上列出商品。我在测试中取得了成功,但我只是遇到了一些标题中带有符号的项目。

此错误不断返回。

XML Error Text: "; nested exception is: 
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference

它告诉我的是我不能简单地传递 & 符号。

为了解决这个问题,我尝试了几种方法:

$string = 'LEUPOLD 66325 4.5-14x50 VX-3 RIFLE SCOPE - SILVER, B&C BOONE & CROCKETT RETICLE';
echo str_replace("&","&",$string);
echo str_replace("&","&",$string);
echo htmlspecialchars($string,ENT_NOQUOTES);
echo htmlspecialchars($string);
echo htmlspecialchars_decode($string);

也这样试过

<![CDATA['.$string.']]>

无论我做什么,当我通过它时,它都不会成功。

感谢大家的帮助。

最佳答案

您提交的数据是 UTF8 格式的吗?如果不是,那可能是您的问题。

http://developer.ebay.com/Devzone/return-management/Concepts/MakingACall.html#utf8encoding

All parameter values should be encoded in UTF-8 format. UTF-8 is the default encoding for API requests.

关于php - 当项目名称包含&符号时,eBay API PHP 和 XML 解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19943243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com