Managing Tweepy API Search

I originally worked out a solution based on Yuva Raj’s suggestion to use additional parameters in GET search/tweets – the max_id parameter in conjunction with the id of the last tweet returned in each iteration of a loop that also checks for the occurrence of a TweepError. However, I discovered there is a far simpler … Read more

Avoid Twitter API limitation with Tweepy

For anyone who stumbles upon this on Google, tweepy 3.2+ has additional parameters for the tweepy.api class, in particular: wait_on_rate_limit – Whether or not to automatically wait for rate limits to replenish wait_on_rate_limit_notify – Whether or not to print a notification when Tweepy is waiting for rate limits to replenish Setting these flags to True … Read more

How can I open a Twitter tweet using the native Twitter app on iOS?

This is how you access other apps from your own. Just find the proper url to send for accessing status. I’ve included a list that should have most of the important ones. Including status finding. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”twitter://status?id=12345″]]; twitter://user?screen_name=lorenb twitter://user?id=12345 twitter://status?id=12345 twitter://timeline twitter://mentions twitter://messages twitter://list?screen_name=lorenb&slug=abcd twitter://post?message=hello%20world twitter://post?message=hello%20world&in_reply_to_status_id=12345 twitter://search?query=%23hashtag Note: It can be important to … Read more

Get All Follower IDs in Twitter by Tweepy

In order to avoid rate limit, you can/should wait before the next follower page request. Looks hacky, but works: import time import tweepy auth = tweepy.OAuthHandler(…, …) auth.set_access_token(…, …) api = tweepy.API(auth) ids = [] for page in tweepy.Cursor(api.followers_ids, screen_name=”McDonalds”).pages(): ids.extend(page) time.sleep(60) print len(ids) Hope that helps.

How to access elements of a JArray (or iterate over them)

There is a much simpler solution for that. Just treat the items of the JArray as JObject. Let’s say we have such array of JSON objects: JArray jArray = JArray.Parse(@”[ { “”name””: “”Croke Park II””, “”url””: “”http://twitter.com/search?q=%22Croke+Park+II%22″”, “”promoted_content””: null, “”query””: “”%22Croke+Park+II%22″”, “”events””: null }, { “”name””: “”Siptu””, “”url””: “”http://twitter.com/search?q=Siptu””, “”promoted_content””: null, “”query””: “”Siptu””, “”events””: null … Read more

How to apply NLTK word_tokenize library on a Pandas dataframe for Twitter data?

In short: df[‘Text’].apply(word_tokenize) Or if you want to add another column to store the tokenized list of strings: df[‘tokenized_text’] = df[‘Text’].apply(word_tokenize) There are tokenizers written specifically for twitter text, see http://www.nltk.org/api/nltk.tokenize.html#module-nltk.tokenize.casual To use nltk.tokenize.TweetTokenizer: from nltk.tokenize import TweetTokenizer tt = TweetTokenizer() df[‘Text’].apply(tt.tokenize) Similar to: How to apply pos_tag_sents() to pandas dataframe efficiently how to use … Read more

How to add a location filter to tweepy module

The streaming API doesn’t allow to filter by location AND keyword simultaneously. Bounding boxes do not act as filters for other filter parameters. For example track=twitter&locations=-122.75,36.8,-121.75,37.8 would match any tweets containing the term Twitter (even non-geo tweets) OR coming from the San Francisco area. Source: https://dev.twitter.com/docs/streaming-apis/parameters#locations What you can do is ask the streaming API … Read more

Is there a way to get a user’s email ID after verifying his/her Twitter identity using OAuth?

The user’s email address can not be retrieved via the API. This is a deliberate design decision by the API team. UPDATE 2015.08.18: It is possible to request an email address from users, but it requires your app to be whitelisted. See https://dev.twitter.com/rest/reference/get/account/verify_credentials for details of the API call and this form to request whitelisting … Read more

Android – Share on Facebook, Twitter, Mail, ecc

Paresh Mayani’s answer is mostly correct. Simply use a Broadcast Intent to let the system and all the other apps choose in what way the content is going to be shared. To share text use the following code: String message = “Text I want to share.”; Intent share = new Intent(Intent.ACTION_SEND); share.setType(“text/plain”); share.putExtra(Intent.EXTRA_TEXT, message); startActivity(Intent.createChooser(share, … Read more

tech