extwitter icon indicating copy to clipboard operation
extwitter copied to clipboard

How do we get the URL of a tweet after using ExTwitter.update/1?

Open mcade opened this issue 6 years ago • 1 comments

I'm trying to get the URL of a tweet after tweeting an update with the ExTwitter.update/1 function. Looking at the twitter update status example, there is a URL to the tweet under the entities field.

But, doing ExTwitter.update("update sample") returns an ExTwitter.Model.Tweet with the entities field all empty:

#ExTwitter.Model.Entities<
  hashtags: [],
  media: [],
  polls: [],
  symbols: [],
  urls: [],
  user_mentions: [],
  ...
>

How am I supposed to get the URL of the tweet after using ExTwitter.update/1 if the entities fields are empty?

Right now I'm just appending the id_str field from the tweet to this url: https://twitter.com/i/web/status/{id_str} but not sure if this is conventional.

Disclaimer: I'm using {:poison, "~> 4.0", override: true} in mix.exs since ExTwitter is set to 3.0.

mcade avatar Jan 23 '20 00:01 mcade

The ExTwitter.Model.Entities.url is for links posted in a Tweet message, not for a URL to the tweet itself. Try tweeting with a URL inside the message and then the Entities model will be populated.

I think the only way to built the URL is the way you are suggesting.

ashleyconnor avatar Apr 17 '20 03:04 ashleyconnor