I'm trying to integrate Twitter API V1.1 with a PHP website. On Twitter my tweet appears as:
SWLaw : Farm & Country is out! http://paper.li/SWLAWCOUK/1346753760 … ▸ Top stories today via @CountrySportsSW @jonesFW @NFUBFGmag
However, on my site the tweet appears as:
RT @SWLawCountry: SWLaw : Farm & Country is out! http://t.co/AU7WCxUxf5â–¸ Top stories today vi@CountrySportsSWS@jonesFWF@NFUBFGmagag
Note the additional characters and special characters.
This seems to be a character encoding issue because the Twitter API (I believe) returns JSON encoded as UTF-8 whereas my web page is encoded as iso-8859-1. I've attempted to fix the issue using PHP's iconv function as follows:
$new_text = iconv("UTF-8", "ISO-8859-1//IGNORE", $new_text);
This produces the following output:
RT @SWLawCountry: SWLaw : Farm & Country is out! http://t.co/AU7WCxUxf5 Top stories today vi@CountrySportsSWS@jonesFWF@NFUBFGmagag
Note that although the special characters have been removed, the additional characters remain and there are missing spaces between some words.
Does anyone know how I can overcome this problem?