LinqToTwitter: How to search tweets of users which i follow?
Using below code, I m getting results for all pubic tweets but i want to query tweets of users which i follow?
var twitterCtx = new TwitterContext(auth);
var searchResults =
from search in twitterCtx.Search
where search.Type == SearchType.Search
&& search.Query == txtQuery.Text
select search;
var searched = searchResults.SingleOrDefault();
Though the Twitter API doesn't offer the option you need, there are a couple things that might come close to what you want: a 'from' operator or a stream.
You can visit the Twitter Search page and view the list of operators that you can include in your LINQ to Twitter Query. One of these operators is 'from'. This appears to be only a single user, but it sounds like you want all of your followers. Anyway, you can experiment on the Twitter Search page to see what results you get and then translate that into the LINQ to Twitter Query.
Another approach might be to use a Filter Stream. It has a Follow property that takes a comma-separated list of users. With the Search above, you're doing request/response. However, streams are different in that you open the connection and listen for a long time, processing responses as they arrive.
Related
I want to find how many tweets of user A did their specific follower B favorited. Is there any way to do this using either Python's tweepy or R's rtweet?
Many thanks!
You can do this, but it is a bit complicated.
You need to use GET favorites/list
This will let you get up to 200 Tweets that User B has liked. You would then have to search through the returned Tweets to see which ones were posted by User A.
The Tweepy documentation for favorites tells you how to do this:
tweets = API.favorites("edent")
Will get you all the tweets I've liked.
I am trying to connect to streaming API of twitter and retrieve tweets keywords using specific keywords. I am using the phirehose library for the same. It says in the twitter documentation that "commas as logical ORs, while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the AND twitter, and ‘the,twitter’ is the OR twitter)."
But I want to search for keywords with AND operator even if there are other words in between. Meaning if we want to search for tweets having Keyword1 AND Keyword2, tweets which have only one keyword should not be retrieved.
Using the settrack function of the phirehose library -
setTrack(array('the , twitter'));
retrieves tweets with either the OR twitter while
setTrack(array('the twitter'));
retrieves tweets with the phrase the twitter and does not retrieve tweets like the busy twitter for example.
Please help.
140dev by Adam Green gives a solution for this by using ``typeenum('words','phrase') NOT NULL DEFAULT 'words'
Please see - http://140dev.com/twitter-api-programming-blog/streaming-api-enhancements-part-2-keyword-collection-database-changes/ and
http://140dev.com/twitter-api-programming-blog/streaming-api-enhancements-part-3-collecting-tweets-based-on-table-of-keywords/
I would like to search for a tweets within a range of between dates by using Twitter API v1.1
let Query query=new QUery(String query);
what is the query thats suits for my question ??
Thanks in advance for reply back.
I suggest setting until to limit your query to an upper date bound, e.g.:
query.setUntil("2014-07-01");
Then step back through the result set, by making subsequent search calls, until you hit your lower date bound.
Be aware that the search API may not contain all Tweets and it may not 'go back' as far as you need. For more information on it, and other query parameters, take a look at Twitter's documentation on searching.
I'd like to find mentions of a hashtag from my friends on Twitter.
At the moment I'm doing:
https://api.twitter.com/1/friends/ids.json?cursor=-1&screen_name=(name)
This returns a list of ids. What I'm then looking at doing is searching for a hashtag mention within that list of ids. Something like:
http://search.twitter.com/search.json?q=#hashtag IN user_id=(1,2,3,4)
One possible (and undesirable) workaround would be to do batch processing of:
http://api.twitter.com/1/users/lookup.json?user_id=(1,2,3,4 ~ 100)
And then construct a query based on the screen names.
Thanks
I'd like to retrieve the tweets for given a hashtag and sort them from the most retweeted to the less retweeted.
The closest thing I've found is using the search call and use the type tag:
E.g.: http://search.twitter.com/search.json?q=TheHashTagHere&result_type=popular
However, I'm not sure on how "popular" option works.
For instance, if it finds 100 tweets with that hashtag I believe it should show the X most retweeted tweets, and if none of those tweets have been retweeted then it should show X of them randomly (or sorted in some other way like the most recent).
Unfortunately, if follows some kind of unknown rule to identify what's popular and what not and even hashtags with thousands of tweets might return only one or two results.
I hope I made myself clear. Thanks in advance :)
PS: I'll use PHP but I think that shouldn't affect the question?
Results will sometimes contain a
result_type field into the metadata
with a value of either "recent" or
"popular". Popular results are derived
by an algorithm that Twitter computes,
and up to 3 will appear in the default
mixed mode that the Search API
operates under. Popular results
include another node in the metadata
called recent_retweets. This field
indicates how many retweets the Tweet
has had.
Source (Emphasis are mine)
Just call with result_type=popular and check the recent_retweets node to see how popular it is. result_type=popular will become the default in an upcome release so beware if you omit this parameter.
Results with popular tweets aren't ordered chronologically. *
If you would like to always have results to show, use result_type=mixed: they will have the result_type in the "metadata" section with a value of "recent", and popular results will have "popular". A small reference about result_types:
mixed: Include both popular and real time results in the response.
recent: return only the most recent results in the response
popular: return only the most popular results in the response.
If a search query has any popular results, those will be returned at the top, even if they are older than the other results. *
*[Twitter API Announcements]
This isn't a programmatic method but rather works in the browser with a chrome extension (HackyBird) :
Install the extension
Search for a phrase e.g. #Social (twitter.com/search?q=%23Social)
Click the extension to sort it (you can adjust the ratio of retweets/likes used for sorting in extension options).
P.S. It'll also sort your or any other user's timeline.