I'm creating an application that consumes the twitter api. I'm retrieving the tweet's and showing users.
In some cases tweets have links, as you can see in the image below.
Reading the api documentation for twitter, I found something called "Enhanced URLs enrichment" that includes the link metadata, containing image url, title, description.
See an example of response I want to get
{
"urls": [
{
"url": "https://exampleurl.com/D0n7a53c2l",
"expanded_url": "http://exampleurl.com/18gECvy",
"display_url": "exampleurl.com/18gECvy",
"unwound": {
"url": "https://www.youtube.com/watch?v=oHg5SJYRHA0",
"status": 200,
"title": "RickRoll'D",
"description": "http://www.facebook.com/rickroll548 As long as trolls are still trolling, the Rick will never stop rolling."
},
"indices": [
62,
85
]
}
]
}
Attention to the object unwound it contains exactly what I need. You can find the above response in the documentation here:
And more about Enhanced URLs enrichment here
I'm retrieving tweets by the endpoint GET statuses/user_timeline
This is my code for retrieving tweets with Twitter4j
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(Constant.getConsumerKeyTwitter());
cb.setOAuthConsumerSecret(Constant.getConsumerSecretTwitter());
cb.setOAuthAccessToken(tokenUser);
cb.setOAuthAccessTokenSecret(secretTokenUser);
cb.setTweetModeExtended(true);
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
List<Status> statuses = twitter.getUserTimeline(userIDToGetTweets);
Using this code, I cant receive the object unwound.
Do you know how I can enable Enhanced URLs enrichment to receive the object unwound
How can I get access to the Twitter API v2? Apps that are associated with a Project within the developer portal will have Essential access to the Twitter API v2. In order to create a project, you must have a developer account. Sign up for a developer account.
Our API platform provides broad access to public Twitter data that users have chosen to share with the world. We also support APIs that allow users to manage their own non-public Twitter information (e.g., Direct Messages) and provide this information to developers whom they have authorized to do so.
The Twitter API v2 includes a few access levels to help you scale your usage on the platform. In general, new accounts can quickly sign up for free, Essential access. Should you want additional access, you may choose to apply for free Elevated access and beyond.
Sadly, that is only available for paying customers.
Premium enrichments are additive metadata included in the response payload of some of the data APIs. They are available in paid subscription plans only.
https://developer.twitter.com/en/docs/tweets/enrichments/overview
So you'll need to get premium API subscription to get the enrichments. Sorry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With