推特流过滤器的位置



推特流API是否可以通过位置字段过滤推文?正如您在下面的示例JSON条目中看到的那样,有"location":"philippines"字段值。现在,我想要的是通过location字段过滤来自那个位置的tweet。但是不要误解我的意思。我不是在谈论地理标签过滤器。

这可能吗?

{"geo":null,"in_reply_to_screen_name":null,"truncated":false,"text":"RT @BreakingNewsPH: Typhoon hits Taiwan after pummeling Philippines: Typhoon Nanmadol slammed intou2026 http://t.co/rF3jbVU #breakingnews","in_reply_to_user_id_str":null,"contributors":null,"retweeted":false,"retweet_count":1,"entities":{"hashtags":[{"text":"breakingnews","indices":[120,133]}],"urls":[{"indices":[100,119],"display_url":"goo.gl/fb/JVdpj","expanded_url":"http://goo.gl/fb/JVdpj","url":"http://t.co/rF3jbVU"}],"user_mentions":[{"indices":[3,18],"name":"Breaking News PH","screen_name":"BreakingNewsPH","id":190144401,"id_str":"190144401"}]},"coordinates":null,"retweeted_status":{"geo":null,"in_reply_to_screen_name":null,"truncated":false,"text":"Typhoon hits Taiwan after pummeling Philippines: Typhoon Nanmadol slammed intou2026 http://t.co/rF3jbVU #breakingnews","in_reply_to_user_id_str":null,"contributors":null,"retweeted":false,"retweet_count":1,"entities":{"hashtags":[{"text":"breakingnews","indices":[100,113]}],"urls":[{"indices":[80,99],"display_url":"goo.gl/fb/JVdpj","expanded_url":"http://goo.gl/fb/JVdpj","url":"http://t.co/rF3jbVU"}],"user_mentions":[]},"coordinates":null,"place":null,"source":"u003Ca href="http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=164577" rel="nofollow"u003EGoogleu003C/au003E","created_at":"Mon Aug 29 04:16:31 +0000 2011","in_reply_to_user_id":null,"user":{"listed_count":19,"favourites_count":0,"profile_sidebar_fill_color":"252429","location":"Philippines","profile_background_tile":false,"lang":"en","profile_link_color":"2FC2EF","description":"Follow us to receive round-the-clock Philippine Breaking News updates directly on your Twitter account!","default_profile_image":false,"default_profile":false,"verified":false,"profile_sidebar_border_color":"181A1E","notifications":null,"time_zone":"Hong Kong","created_at":"Mon Sep 13 05:14:02 +0000 2010","followers_count":804,"following":null,"profile_use_background_image":true,"profile_background_image_url_https":"https://si0.twimg.com/images/themes/theme9/bg.gif","profile_image_url":"http://a3.twimg.com/profile_images/1130204413/breakingnewsph-logo-small_normal.png","show_all_inline_media":false,"follow_request_sent":null,"geo_enabled":false,"profile_background_color":"1A1B1F","protected":false,"contributors_enabled":false,"profile_background_image_url":"http://a1.twimg.com/images/themes/theme9/bg.gif","url":"http://www.breakingnews.ph","screen_name":"BreakingNewsPH","name":"Breaking News PH","friends_count":210,"profile_image_url_https":"https://si0.twimg.com/profile_images/1130204413/breakingnewsph-logo-small_normal.png","id":190144401,"id_str":"190144401","is_translator":false,"statuses_count":51981,"utc_offset":28800,"profile_text_color":"666666"},"in_reply_to_status_id":null,"favorited":false,"id":108030240370073602,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"id_str":"108030240370073602"},"place":null,"source":"web","created_at":"Mon Aug 29 04:23:44 +0000 2011","in_reply_to_user_id":null,"user":{"listed_count":0,"favourites_count":1,"profile_sidebar_fill_color":"FFF7CC","location":"cabuyao,Laguna PHILIPINES","profile_background_tile":false,"lang":"en","profile_link_color":"FF0000","description":"Prudence keeps life safe, but it does not often make it happy.","default_profile_image":false,"default_profile":false,"verified":false,"profile_sidebar_border_color":"F2E195","notifications":null,"time_zone":"Alaska","created_at":"Sun Nov 14 09:15:11 +0000 2010","followers_count":32,"following":null,"profile_use_background_image":true,"profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/188170056/Picture_276.jpg","profile_image_url":"http://a2.twimg.com/profile_images/1423110432/271010_220561634650699_100000905924979_647505_1229915_n_normal.jpg","show_all_inline_media":true,"follow_request_sent":null,"geo_enabled":false,"profile_background_color":"BADFCD","protected":false,"contributors_enabled":false,"profile_background_image_url":"http://a1.twimg.com/profile_background_images/188170056/Picture_276.jpg","url":null,"screen_name":"emerlyn14","name":"Emerlyn Cantalejo","friends_count":215,"profile_image_url_https":"https://si0.twimg.com/profile_images/1423110432/271010_220561634650699_100000905924979_647505_1229915_n_normal.jpg","id":215568114,"id_str":"215568114","is_translator":false,"statuses_count":270,"utc_offset":-32400,"profile_text_color":"0C3E53"},"in_reply_to_status_id":null,"favorited":false,"id":108032058986729472,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"id_str":"108032058986729472"}

查看twitter流api: https://dev.twitter.com/docs/streaming-api/methods#locations

指定要跟踪的一组边界框。只有两者都是的推文使用地理标记API创建,并从跟踪对象中放置边界框将包含在流中-用户的位置字段不用于过滤tweet(例如,如果用户有他们的位置)设置为"San Francisco",但这条推文并不是使用Geotagging API并且没有geo元素,它将不会包含在流)。边界框指定为逗号分隔的列表经纬度对,第一对表示西南盒子的一角。例如locations=-122.75,36.8,-121.75,37.8会追踪来自旧金山地区的推文。多个边界可以通过连接纬度/经度对来指定框例如:locations=-122.75,36.8,-121.75,37.8,-74,40,-73,41旧金山和纽约的推特。

就像track参数一样,查询受制于track限制,在轨道限制中描述,受访问角色的限制;在status/filter方法中描述。的数量和大小边界框是有限的。边界框可以达到360度经度乘以180度纬度,您可以指定最多25度边界框。一个360度乘180度的盒子将覆盖整个地球。更高的访问级别提供额外的边界框。

边界框是逻辑or。位置参数可以组合使用,但请注意,所有项在逻辑上都是ORd,因此查询字符串Track =twitter&locations=-122.75,36.8,-121.75,37.8匹配任何包含"Twitter"一词的推文(即使是非地理位置的推文)或即将到来从旧金山地区。

值:经纬度对,以逗号分隔。第一对指定方框的西南角。方法:状态/过滤器

示例:创建一个名为"locations"的文件,其中包含,不包含引号,这个短语"位置= -122.75,36.8,-121.75,37.8,-74年,40岁的-73年,41"然后执行:

curl -d @locations https://stream.twitter.com/1/statuses/filter.json
-uAnyTwitterUser:Password. 

您将收到来自旧金山和纽约的所有地理标记推文纽约市区。

嗯…twitter不会过滤位置字段,只有地理标签,如果你想过滤位置,你必须在json响应中写一个过滤器来过滤位置。这真的很低效,你会失去很多推特,因为你只收到不到10%的公众状态:

状态/样本

返回所有公共状态的随机样本。默认访问级别"Spritzer"提供了Firehose的一小部分,非常接近所有公共状态的1%。"Gardenhose"访问级别提供了一个更适合数据挖掘和研究应用程序的比例,这些应用程序希望更大比例的样本具有统计显著性。目前,Gardenhose的回报率大约是所有公众地位的10%。请注意,这些比例可能会因交通量的变化而进行未通知的调整。

,你也可以阅读:

状态/消防带

返回所有公共状态。Firehose不是一般可用的资源。很少有应用程序需要这种级别的访问。创造性地使用其他资源和各种访问级别的组合可以满足几乎每个应用程序用例。

. .你只有两个选择,1)使用位置过滤器过滤整个国家,或者2)只接收1%的公共状态并过滤它,也许阅读它可以帮助你:

再见,快乐编码

相关内容

  • 没有找到相关文章

最新更新