4

I have been testing my PHP app to list items on eBay using their Trading API. I have been having success in my testing but I just came accross some items with ampersand in the title.

This error keeps getting returned.

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

What its telling me is that I cant simply pass the ampersand symbol.

To remedy the problem I have tried several things:

$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);

also tried it like this

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

No matter what I do, it does not succeed when I pass it through.

Thanks all for your help.

Cray
  • 2,774
  • 7
  • 22
  • 32
Shawn Abramson
  • 701
  • 1
  • 5
  • 18
  • 1
    Is the data you're submitting in UTF8? That could be your problem if it's not. http://developer.ebay.com/Devzone/return-management/Concepts/MakingACall.html#utf8encoding – Machavity Nov 13 '13 at 01:03
  • Thanks for your response. That was the problem. You should present your comment as an answer so I can accept it. Thanks! – Shawn Abramson Nov 13 '13 at 14:02

1 Answers1

4

Is the data you're submitting in UTF8? That could be your problem if it's not.

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.

Machavity
  • 30,841
  • 27
  • 92
  • 100