推特API部分参数过滤规则

1.实时推文

https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters

track

A comma-separated list of phrases which will be used to determine what Tweets will be delivered on the stream. A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case. By this model, you can think of 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).(逗号可以视为‘或’,空格可以视为‘与’)

The text of the Tweet and some entity fields are considered for matches. Specifically, the text attribute of the Tweet, expanded_url and display_url for links and media, text for hashtags, and screen_name for user mentions are checked for matches.

Each phrase must be between 1 and 60 bytes, inclusive.

Exact matching of phrases (equivalent to quoted phrases in most search engines) is not supported.

Punctuation and special characters will be considered part of the term they are adjacent to. In this sense, “hello.” is a different track term than “hello”. However, matches will ignore punctuation present in the Tweet. So “hello” will match both “hello world” and “my brother says hello.” Note that punctuation is not considered to be part of a #hashtag or @mention, so a track term containing punctuation will not match either #hashtags or @mentions.

UTF-8 characters will match exactly, even in cases where an “equivalent” ASCII character exists. For example, “touché” will not match a Tweet containing “touche”.

Non-space separated languages, such as CJK are currently unsupported.

URLs are considered words for the purposes of matches which means that the entire domain and path must be included in the track query for a Tweet containing an URL to match. Note that display_url does not contain a protocol, so this is not required to perform a match.

Twitter currently canonicalizes the domain “www.example.com” to “example.com” before the match is performed, so omit the “www” from URL track terms.

Finally, to address a common use case where you may want to track all mentions of a particular domain name (i.e., regardless of subdomain or path), you should use “example com” as the track parameter for “example.com” (notice the lack of period between “example” and “com” in the track parameter). This will be over-inclusive, so make sure to do additional pattern-matching in your code. See the table below for more examples related to this issue.

Track examples:

Parameter valueWill match...Will not match...
Twitter

TWITTERtwitter “Twitter” twitter. #twitter @twitter http://twitter.com

TwitterTracker#newtwitter

Twitter’sI like Twitter’s new designSomeday I’d like to visit @Twitter’s office
twitter api,twitter streaming

The Twitter API is awesomeThe twitter streaming service is fast Twitter has a streaming API

I’m new to Twitter
example.comSomeday I will visit example.comThere is no example.com/foobarbaz
example.com/foobarbaz

example.com/foobarbazwww.example.com/foobarbaz

example.com
www.example.com/foobarbaz www.example.com/foobarbaz
example com

example.comwww.example.com foo.example.com foo.example.com/bar I hope my startup isn’t merely another example of a dot com boom!

 

2.人的历史推文

https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html

Parameters

NameRequiredDescriptionDefault ValueExample
user_idoptionalThe ID of the user for whom to return results. 12345
screen_nameoptionalThe screen name of the user for whom to return results. noradio
since_idoptionalReturns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets that can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available. 12345
countoptionalSpecifies the number of Tweets to try and retrieve, up to a maximum of 200 per distinct request. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if include_rts is not supplied. It is recommended you always send include_rts=1 when using this API method.  
max_idoptionalReturns results with an ID less than (that is, older than) or equal to the specified ID. 54321
trim_useroptionalWhen set to either true , t or 1 , each Tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object. true
exclude_repliesoptionalThis parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the countparameter will mean you will receive up-to count tweets — this is because the count parameter retrieves that many Tweets before filtering out retweets and replies. true
include_rtsoptionalWhen set to false , the timeline will strip any native retweets (though they will still count toward both the maximal length of the timeline and the slice selected by the count parameter). Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will still contain a full user object. false

3.关键词历史推文(搜索推文)

https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators

此方法不支持使用逗号 “,” 标识关键词的或关系。

Limit your searches to 10 keywords and operators(搜索词数量限制在10个以内)

Standard search operators

The query can have operators that modify its behavior.  Below are examples that illustrate the available operators in standard search:

OperatorFinds Tweets...
watching nowcontaining both “watching” and “now”. This is the default operator.
“happy hour”containing the exact phrase “happy hour”.
love OR hatecontaining either “love” or “hate” (or both).
beer -rootcontaining “beer” but not “root”.
#haikucontaining the hashtag “haiku”.
from:interiorsent from Twitter account “interior”.
list:NASA/astronauts-in-space-nowsent from a Twitter account in the NASA list astronauts-in-space-now
to:NASAa Tweet authored in reply to Twitter account “NASA”.
@NASAmentioning Twitter account “NASA”.
politics filter:safecontaining “politics” with Tweets marked as potentially sensitive removed.
puppy filter:mediacontaining “puppy” and an image or video.
puppy -filter:retweetscontaining “puppy”, filtering out retweets
puppy filter:native_videocontaining “puppy” and an uploaded video, Amplify video, Periscope, or Vine.
puppy filter:periscopecontaining “puppy” and a Periscope video URL.
puppy filter:vinecontaining “puppy” and a Vine.
puppy filter:imagescontaining “puppy” and links identified as photos, including third parties such as Instagram.
puppy filter:twimgcontaining “puppy” and a pic.twitter.com link representing one or more photos.
hilarious filter:linkscontaining “hilarious” and linking to URL.
puppy url:amazoncontaining “puppy” and a URL with the word “amazon” anywhere within it.
superhero since:2015-12-21containing “superhero” and sent since date “2015-12-21” (year-month-day).
puppy until:2015-12-21containing “puppy” and sent before the date “2015-12-21”.
movie -scary :)containing “movie”, but not “scary”, and with a positive attitude.
flight :(containing “flight” and with a negative attitude.
traffic ?containing “traffic” and asking a question.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值