PHP: How to use the Twitter API's data to convert URLs, mentions, and hastags in tweets to links?

后端 未结 7 591
盖世英雄少女心
盖世英雄少女心 2021-02-05 14:52

I\'m really stumped on how Twitter expects users of its API to convert the plaintext tweets it sends to properly linked HTML.

Here\'s the deal: Twitter\'s JSON API sends

相关标签:
7条回答
  • 2021-02-05 15:18

    Regarding vita10gy's helpful json_tweet_text_to_HTML(), I found a tweet that it could not format correctly: 626125868247552000.

    This tweet has a nonbreaking space in it. My solution was to replace the first line of the function with the following:

    $return = str_replace("\xC2\xA0", ' ', $tweet->text);
    

    Performing a str_replace() on   is covered here.

    0 讨论(0)
提交回复
热议问题