Right, based on this question Tweet clickable links with twitteroauth?,
How do I actually parse the entire string and replace the t.co link portion with a
<a href=""></a>
portion?
For example i tweet this –
Hey check out this link www.google.com
and in my website currently it shows
Hey check out this link http://t.co/generatedlink
So how do i parse it and make it into this
Hey check out this link <a href="http://t.co/generatedlink">http://t.co/generatedlink</a>
which would display like this in my website:
Hey check out this link http://t.co/generatedlink
How am I able to detect that a certain portion of the tweet text has a link inside it? Or am I going about this wrong?
You need to understand Twitter Entities.
When you request the tweet, make sure you use include_entities=true
For example:
In the response, you will see an element called “entities” inside that, you will see “urls”.
That will contain all the URLs and their position (indices) within the tweet.