URL for a link to Twitter for a specific tweet

2020-02-17 04:18发布

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
6条回答
孤傲高冷的网名
2楼-- · 2020-02-17 04:49

You can use

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

查看更多
冷血范
3楼-- · 2020-02-17 04:52

I've been tried it. It's work good: - Web : https://twitter.com/statuses/ID - Mobile && Web: https://twitter.com/User_ID/statuses/Tweet_ID

I hope it's helpful for you.

查看更多
我命由我不由天
4楼-- · 2020-02-17 04:53

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}

查看更多
Rolldiameter
5楼-- · 2020-02-17 04:55

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

查看更多
一纸荒年 Trace。
6楼-- · 2020-02-17 05:03

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]

查看更多
我只想做你的唯一
7楼-- · 2020-02-17 05:03

You can use like:

http://twitter.com/itdoesnotmatter/status/[YOURID]

Twitter redirect based on status ID not username.

It works for desktop and mobile.

查看更多
登录 后发表回答