Twitter search (atom) API - exclude retweets - twitter

I am using the Atom search API from Twitter. Now I present all (newest 5) tweets with a certain word. But unfortunately, many people retweet this one post and I get the same post 5 times.
Can I exclude retweets? If so, how?

I've been successfully excluding retweets by adding +exclude:retweets at the end of my search query.

I've done that and I'll share how you accomplish this. This would be your search query:
http://search.twitter.com/search.atom?lang=en&rpp=100&q=[yourpost-value]-filter:retweets
This will exclude the retweets 100% and it worked for me :). If you have a problem with this, here is the alternate way:
Concatenate -filter:retweets within the function you are calling, here is an example:
if(isset($_POST['q'])){
$q = $_POST['q']."-filter:retweets";
}
Now you just need to execute you search query:
http://search.twitter.com/search.atom?lang=en&rpp=100&q=[post-value]
I hope this helps, have fun with programming :)

Related

Geocode in Twitter API doesn't work

Can somebody tell me about Twitter Search API with geolocation filter?
I'm trying to use
GET https://api.twitter.com/1.1/search/tweets.json?oauth_consumer_key=*************&oauth_token=************-**********************&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1502873578&oauth_nonce=*****&oauth_version=1.0&oauth_signature=%****************%3D&q=ffdp&geocode=45.458626,9.181872999999996,150mi
45.458626,9.181872999999996 - Milan, Italy
And I have no statuses, but if I try this query, using advanced search:
https://twitter.com/search?l=&q=ffdp%20near%3A%22Milan%2C%20Lombardy%22%20within%3A15mi&src=typd&lang=en
I have some statuses.
Can somebody describe me, please, does it work? Or, maybe there are some mistake in my request?
The link for your advanced search returns tweets that are much older than a week. In general, very few tweets have latitude and longitude embedded with them. Also, the Twitter Search API will only return tweets from the past week or so. For both these reasons you are not seeing any tweets from Milan.
Try setting up your retrieval parameters like this
["geocode" => "Lon,Lat,Radius"]
for example
["geocode" => "37.781157,-122.398720,1mi"]

Google youtube API, how do i search for specific keyword?

I want to search for keyword related youtube videos, I'm using youtube getdata API.
Reading documentation I came up with this:
http://gdata.youtube.com/feeds/api/videos/-/". urlencode($kwd) ."?orderby=viewCount&max-results=". $max ."&alt=json
But this is not a real search, it gives urls taged with keyword... Youtubes internal search works quite differently I imagine, because comparing results don't match at all.
Any ideas?
The URL you offer does a search for any videos in a category where the category includes your keyword. What you want to do instead is to send a query string:
"https://gdata.youtube.com/feeds/api/videos?q=". urlencode($kwd) ."&orderby=viewCount&max-results=". $max ."&alt=json"
This way the feed will match right on the videos rather than the categories.
In the newer v3 of the API, your call would look like:
"https://www.googleapis.com/youtube/v3/search?part=snippet&q=".urlencode($kwd)."&maxResults=".$max."&order=viewCount&key={YOUR_API_KEY}"
Use Data API v3, search->list method.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=term&key={YOUR_API_KEY}
In my opinion, I would use the "q" parameter, for example to search for "dog"
var request = gapi.client.youtube.search.list({
part: 'snippet',
q: "dog"
});
But I'm just a noob the others guys answers are probably better.

Youtube API feedapplying filter

I am using following rss feed to get videos from youtube. works fine.
http://gdata.youtube.com/feeds/api/users/zeetv/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile;
now i like to apply certain filter... for example: listing videos which has "Episode" in title.
http://gdata.youtube.com/feeds/api/users/zeetv/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile&q=Episode;
But it doesnot filter out the videos,which matches "episode", instead it list all.
i had checked this link https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters
and applied query string.
anyhelp is much appreciated. Thanks
It seems like you can't query a users videos, like that.
You have to build your query like this: http://gdata.youtube.com/feeds/api/users/zeetv/uploads?q=Episode&fields=entry(title)
you can read more about the fields syntax here: https://developers.google.com/youtube/2.0/developers_guide_protocol_partial#Fields_Formatting_Rules
The link provided in the question now has the answer. You should perform a search for the term you want and filter by author:
https://gdata.youtube.com/feeds/api/videos?q=episode&author=zeetv

twitter: search hashtags in a twitter list

i'm trying to use 'Twitter Search Widget' here searching an #hashtag in a 'Twitter List', but i can't fix the exact query. Someone did it before me?
Thanks in advance, sorry for my poor english.
Francesco
There doesn't seem to be a way to directly search twitter lists using the widget. If you look at the "operators" link on this page:
https://twitter.com/#!/search-home
You can use "from:userid OR from:userid2 #hashtag" to search for #hashtag tweets from specific users, and hashtags work fine - so you could manually build a search for a list if you wanted.
You can see what operators search can take by looking at the advanced search page here:
https://twitter.com/#!/search-advanced
If i understand correctly, you're trying to search for tweets containing a specific #hashtag, authored uniquely by certain list members?
If this is the case, say for example your looking for the hashtag #COVID19 relayed only by #Twitter's list of official Twitter accounts, you could do it with the following Twitter search query:
#COVID19 list:84839422
Try it...
The structure is quite simple...
[#hashtag] list:[list_id]
You can find list IDs by looking at the URL line in the browser when opening lits on Twitter. For example, here is the URL of #Twitter's official accounts liss:
https://twitter.com/i/lists/84839422
The list ID are the digits after the last /.

Twitter API - Display all tweets with a certain hashtag?

How would I go about displaying tweets that contain a certain hashtag using the Twitter API? Thanks
I'd also like to know if there is a way to get all tweets from a certain hashtag in a separate file, also the ones that don't show up in your feed anymore. I suppose that's what the earlier question was about, too.
This answer was written in 2010. The API it uses has since been retired. It is kept for historical interest only.
Search for it.
Make sure include_entities is set to true to get hashtag results. See Tweet Entities
Returns 5 mixed results with Twitter.com user IDs plus entities for the term "blue angels":
GET http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&with_twitter_user_id=true&result_type=mixed
UPDATE for v1.1:
Rather than giving q="search_string" give it q="hashtag" in URL encoded form to return results with HASHTAG ONLY. So your query would become:
GET https://api.twitter.com/1.1/search/tweets.json?q=%23freebandnames
%23 is URL encoded form of #. Try the link out in your browser and it should work.
You can optimize the query by adding since_id and max_id parameters detailed here. Hope this helps !
Note: Search API is now a OAUTH authenticated call, so please include your access_tokens to the above call
Updated
Twitter Search doc link:
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
The answer here worked better for me as it isolates the search on the hashtag, not just returning results that contain the search string. In the answer above you would still need to parse the JSON response to see if the entities.hashtags array is not empty.

Resources