Getting the app-id for a promoted tweet


#1

Hi,

I’d like to identify the app id (for example: com.twitter.android for Android and 333903271 for iOS) that is promoted for each tweet, I’m looking for a better way to do that other than following the expanded_url - any ideas?


#2

Hi @dimapv - Which expanded_url are you using? Can you c/p the request and response so I know we’re talking about the same thing?

The “source” field can be used to view which app created the Tweet. Tweets must be parsed individually for this information.


#3

I use statuses/lookup.json (from the regular API) to get details about promoted tweets by id, and then for each tweet we have [“entities”][“urls”][0][“expanded_url”].

I noticed that cards have this information in iphone_app_id and googleplay_app_id - how can I discern which card is displayed in which tweet?

Regarding the “source” field - I’m not interested in the app that created the tweet but rather the app that the tweet promotes…

Thanks!


#4

Ok, I’ve solved both problems by parsing the expanded url of a tweet… for those interested:

  1. If a tweet contains a card it will have an expanded_url inside one of its entities that points to a url of the form https://cards.twitter.com/cards/:account_id/:card_id

  2. using the accounts/:account_id/cards/image_app_download endpoint we can get the details about the card and extract the application id from there

@jillblaz - Are those assumptions correct? is there a more robust / future-proof way of doing what I want (if the format of the card url changes…)?


#5

@dimapv - Yes, this is true! Totally misunderstood your initial question, sorry about that.

This is the best way to get card information based on Tweet ID. Since the card information is not included in the Tweet json, you have to get the card ID from the expanded_url and then use the card endpoint, as you described.