Open ianchanning opened 4 years ago
It looks like you could do a search and replace in the text via the urls. This is the example JSON they provide in the earlier extended tweets documentation ( https://developer.twitter.com/en/docs/twitter-api/v1/tweet-updates#chars280 ):
"extended_tweet": {
"full_text": "Can’t fit your Tweet into 140 characters? 🤔\n\nWe’re trying something new with a small group, and increasing the character limit to 280! Excited about the possibilities? Read our blog to find out how it all adds up. 👇\nhttps://t.co/C6hjsB9nbL",
"display_text_range": [
0,
239
],
"entities": {
"hashtags": [
],
"urls": [
{
"url": "https://t.co/C6hjsB9nbL",
"expanded_url": "https://cards.twitter.com/cards/gsby/4ubsj",
"display_url": "cards.twitter.com/cards/gsby/4ub…",
"unwound": {
"url": "https://cards.twitter.com/cards/gsby/4ubsj",
"status": 200,
"title": "Giving you more characters to express yourself",
"description": null
},
"indices": [
216,
239
]
}
],
You should be able to loop through the extended_tweet
and replace all the urls found in the urls
array with a formatted link based on their suggestion:
- Use the “url” value of a URL entity for the href attribute of an anchor tag.
- Use the “expanded_url” value of a URL entity for the title attribute of an anchor tag, so that when users hover over the link they see the fully expanded URL.
- Use the “display_url” value of a URL entity for the displayed text between opening & closing anchor tags. If you prefer not to display the truncated format, use the full “expanded_url” instead.
So something like <a href="$url['url']" title="$url['expanded_url']>$url['display_url']</a>
Unfortunately I haven't got the time to get more involved but I think that's the basic solution
Question from @patrickbootscec in https://github.com/jdelamater99/Twitter-RSS-Parser/issues/8#issuecomment-673584226 that should be a separate issue: