URL for a link to Twitter for a specific tweet

Twitter

Twitter Problem Overview


I have some Javascript that uses Twitter API to get tweets. I parse the data and use jQuery to generate HTML for the DOM.

An aspect of what I want to display is a "View this tweet" link -- yeah, sorta sounds silly, but it allows a user to get a URL for a specific tweet.

I am generating an a tag with an href. The URL is of the form:

http://twitter.com/{twitter-user-id}/status/{tweet-status-id}

where the content in curly braces is actual data extracted from the tweet (no, I am not including the curly braces). For example:

http://twitter.com/Atechtrader/status/57432099984130050

What happens in operation is that this works for some tweets, but not others. For the ones that fails, the Twitter server responds with content that says the requested page does not exist.

Am I doing something wrong?

Twitter Solutions


Solution 1 - Twitter

https://twitter.com/statuses/ID should work.
it will redirect to the needed status.

Solution 2 - Twitter

Unfortunately, all of the answers provided so far rely on an HTTP redirect.

The direct link is of the form: https://twitter.com/i/web/status/{tweet-status-id}

Solution 3 - Twitter

FYI: id_str is the variable you need to call instead of id

id_str should be taken from the tweet object and replaced in https://twitter.com/statuses/[id_str]

Solution 4 - Twitter

You can use like: >http://twitter.com/itdoesnotmatter/status/[YOURID]

Twitter redirect based on status ID not username.

It works for desktop and mobile.

Solution 5 - Twitter

You can use

'https://www.twitter.com/'+ user.screen_name+'/status/' + id_str

Solution 6 - Twitter

I've been tried it. It's work good:

I hope it's helpful for you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZhamiView Question on Stackoverflow
Solution 1 - TwitterSagiv OfekView Answer on Stackoverflow
Solution 2 - TwitterJeff PuckettView Answer on Stackoverflow
Solution 3 - TwitterTrevor JordetView Answer on Stackoverflow
Solution 4 - TwitterSeyfi DertliView Answer on Stackoverflow
Solution 5 - TwitterPawan KotakView Answer on Stackoverflow
Solution 6 - TwitterKiều Văn TháiView Answer on Stackoverflow