Skip to content
Advertisement

Tweets from API have strange characters (Abraham library)

I’m using this library (Abraham twitteroauth) to pull tweets from a timeline like so…

$connection = getConnectionWithAccessToken(TOKEN, TOKEN_SECRET);
$tweets = $connection->get('statuses/user_timeline', array('screen_name' => 'francis_narcise'));

And everything works fine, but the output has a lot of funny characters lik ““” in place of double quotes.

Does anyone know why this happens?

Advertisement

Answer

The results you get from the library are in UTF-8. Set the character set of your output correctly or use the correct escaping functionality.

For example, when you are outputting to HTML, you can set the character set of the page to UTF-8:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Or, you can escape the characters with htmlentities:

echo htmlentities($tweet);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement