The urls entity returns the url to the tweet itself, not url extracted from tweet text

extended-tweet

#1

Hi,

When fetching users_timeline, I try to extract the url in the tweet. However, the response I’m getting has the url pointing to the tweet itself.

Here is the tweet I’m trying to fetch. https://twitter.com/i/web/status/785799141310029824.
There is https://smarp.smh.re/3R6 in the tweet. However, the response I got in urls entity is https://twitter.com/i/web/status/785799141310029824

Here is the json response I got

{
    "created_at": "Tue Oct 11 11:08:09 +0000 2016",
    "id": 7.8579914131003e+17,
    "id_str": "785799141310029824",
    "text": "#Digital branding expert Juntae DeLane [@JuntaeDeLane] on Smarp's latest #Influencer Insights #blog series.\u2026 https:\/\/t.co\/vcjbxW6bU1",
    "truncated": true,
    "entities": {
      "hashtags": [
        {
          "text": "Digital",
          "indices": [
            0,
            8
          ]
        },
        {
          "text": "Influencer",
          "indices": [
            73,
            84
          ]
        },
        {
          "text": "blog",
          "indices": [
            94,
            99
          ]
        }
      ],
      "symbols": [
        
      ],
      "user_mentions": [
        {
          "screen_name": "JuntaeDeLane",
          "name": "Juntae DeLane",
          "id": 162611402,
          "id_str": "162611402",
          "indices": [
            40,
            53
          ]
        }
      ],
      "urls": [
        {
          "url": "https:\/\/t.co\/vcjbxW6bU1",
          "expanded_url": "https:\/\/twitter.com\/i\/web\/status\/785799141310029824",
          "display_url": "twitter.com\/i\/web\/status\/7\u2026",
          "indices": [
            109,
            132
          ]
        }
      ]

#2

You need to add the parameter tweet_mode=extended to all your urls that return Tweets

The key here is the truncated: true part of the response


API Tweet shortURL doesn't match Actual Tweet shortURL
#3

Does it work for retweets - full length which includes their handle and the url?


#4

Yes it works for all endpoints that return tweet objects


#5

Thanks @richardhyland :wink:

Documentation on this is in the new extended Tweets page on dev.twitter.com (note that the replies changes described there have not yet been rolled out) - and this will be added across the endpoint documentation in future.


#6

Thanks, this works for me


#7