简体   繁体   中英

Why is the text from the twitter API feed showing different characters in the tweet text and the retweet_status text?

I've just started using the twitter API 1.1, using PHP/curl to access the feed, and I've noticed that when I recieve the JSON feed, tweets are formatted containing strange characters at the end of the tweet object's text property but not in the retweeted_status->text property (see below, irrelevant data removed).

[1] => stdClass Object
        (

            [text] =>blah blah blah blah blah blah i…

                )

            [retweeted_status] => stdClass Object
                (

                    [text] => blah blah blah blah blah blah.


                        )

       )

The i… is showing up when the tweet text is printed to the screen. These characters don't appear to be foreign characters such as accents or cedillas etc and it doesn't seem to be a failure in encoding as the retweeted_status->text property is correct.

Can anyone help point me at where I should be looking for the source of this problem? I assume I can't be the only person who's encountered this problem, but I haven't found any other solutions yet.

Thank you.

I was running into a similar problem, here are two things you can try,

htmlentities($td->text, ENT_NOQUOTES, 'UTF-8');

where td is the object, and text is the text. You can also try:

utf8_decode($td->text)

but I found that the first option worked a bit better for me. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM