Twitterã«ãããUserStreamã®çµçã¨ãã®ä»£ç¨
UserStreamã®çµç
Twitterã¯8æ17æ¥ã«UserStreamãå»æ¢ãã¾ããã
ããã¯ãã¤ãã¿ã¼ã¯ã©ã¤ã¢ã³ãä½è ã¨ãã¦é常ã«å°ãã¾ãã ãã¹ã¯ãããã¯ã©ã¤ã¢ã³ãã¯Webãªã©ã®å ¬å¼ã«å¯¾ãã¦ãªã¢ã«ã¿ã¤ã ã§ãã¤ã¼ããåä¿¡ã§ããã¨ãããããæå³ä¸ã¤ã®é åã ã£ãããã§ããã UserStreamããªãã¨ãç¡éã«APIãå©ããå ¬å¼ã®ComsumerKeyãªã©ã使ããªãéã1åã«1åããã¿ã¤ã ã©ã¤ã³ã®åå¾ãã§ããªããªã£ã¦ãã¾ãã¾ãã
ã¨ããã§ãTwitterã«ã¯å¹¸ãã«ãstatuses/filter.jsonã¨ããã¹ããªã¼ãã³ã°APIãåå¨ãã¾ãã (ãã¡ãã¯statuses/sample.jsonã¨ã¨ãã«å»æ¢äºå®ã¯ãªããã)
ãã®ã¹ããªã¼ãã³ã°APIãæ§ã ãªæ¡ä»¶ãæå®ãã¦ãã®æ¡ä»¶ã«ãã£ããã¤ã¼ãããªã¢ã«ã¿ã¤ã ã§åä¿¡ããã¨ãããã®ãªã®ã§ããã ã¦ã¼ã¶ã¼ãè¤æ°æå®ãã¦ãã¤ã¼ããåä¿¡ãããã¨ãå¯è½ã§ãããããUserStreamã®ä»£ç¨åã¨ãã¦ä½¿ç¨ãããã¨ãã§ãã¾ãã
UserStreamã®ä»£ç¨å
statuses/filter.jsonã§ã¯ãã©ã¡ã¼ã¿ã«track(æ¤ç´¢ãã¼ã¯ã¼ããæå®)ãfollow(æ¤ç´¢å¯¾è±¡ã¦ã¼ã¶ã¼ã®IDãæå®)ã使ããã«ã³ãåºåãã§æ¡ä»¶ãæå®ãã¾ãã
followã«å¯¾ãã¦èªåããã©ãã¼ãã¦ããã¦ã¼ã¶ã¼ã®Idãæå®ãããã¨ã§æ¬ä¼¼çã«ã¦ã¼ã¶ã¼ã¹ããªã¼ã ãåç¾ã§ãã¾ãã
ãã®æ¹æ³ã§ã¯å¾æ¥ã®UserStreamã«å¯¾ãã¦ä»¥ä¸ã®ãããªå¶éãããã¾ãã
- èªåã®ãã¤ã¼ãããµãã¼ããããRTãããéç¥ããã©ãã¼ãããéç¥ãªã©ãåãåããã¨ã¯ä¸å¯è½
- èªåã®ãã©ãã¼ãã¦ããã¦ã¼ã¶ã¼ãèªåã®ãã©ãã¼ãã¦ããªãã¦ã¼ã¶ã¼ã«å¯¾ãã¦æãããªãã©ã¤ãåä¿¡ (userstreamã«repliesãæå®ããã¨ãã®æåã¨åãï¼)
- 5000ã¦ã¼ã¶ã¼ã¾ã§åå¾å¯è½
- éå ¬éã¢ã«ã¦ã³ãã®ãã¤ã¼ãã¯åä¿¡ã§ããªã
- statuses/filter ã¯1èªè¨¼ããã1ã¤ãã使ããªã (è¤æ°ã¹ããªã¼ã ã使ç¨ãããã¨ã¯ä¸å¯è½)
ãããUserStreamãå»æ¢ããã¦ãªã¢ã«ã¿ã¤ã ã«ãã¤ã¼ããåä¿¡ã§ããªããªãããã¯ã¾ãã ã¨æããã¾ãã®ã§ãåã¯ã©ã¤ã¢ã³ãä½è ã«ã¯ãã®æ¹æ³ãæ´»ç¨ãã¦ã»ããã¨æãã¾ãã
CoreTweetã§ã®ãµã³ãã«ã¯ä»¥ä¸ã®æ§ã«ãªãã¾ãã
var userList = await Tokens.Friends.IdsAsync(screen_name => "cucmberium", count => 5000); var param = new Dictionary<string, object> { { "follow", string.Join(",", userList) } }; iObservable = Tokens.Streaming.FilterAsObservable(param); iObservable .SubscribeOn(NewThreadScheduler.Default) .Catch( (Exception ex) => iObservable.DelaySubscription(TimeSpan.FromSeconds(15)).Retry()) .Repeat() .Subscribe(x => { çç¥ ããã§ã¦ã¼ã¶ã¼ã®ãªãã©ã¤ããªãã¤ã¼ãã«é¢ããå¦çãæã })
ç°¡åã§ããã ãã®æ¹æ³ãã¦ã¼ã¶ã¼ã®ä»»æã®ãªã¹ããæ¤ç´¢ãåæ§ã®æ¹æ³ã§ãªã¢ã«ã¿ã¤ã ã«åå¾ã§ãããããã®ã§ä¾¿å©ã§ãã
Flantterã®ä»å¾ã®ã¢ãããã¼ãã«ã¤ãã¦
æ¬å½ã¯ãã£ã¡ãã¡ã¤ã³ã§æ¸ãããã£ãã®ã§ãããã£ãããªã®ã§Flantterã§ã©ããã£ã¦ã¦ã¼ã¶ã¼ã¹ããªã¼ã ãã©ã®ããã«åç¾ããããè¸ã¾ããä¸ã§ä»å¾ã«ã¤ãã¦è§¦ãããã¨æãã¾ãã
- UserStreamã¯FilterStreamã§å¯¾å¿ã§ããã¨ããã¾ã§ããç¨åº¦å¯¾å¿
- ã¤ãã³ãã«ã©ã å»æ¢ãMentionã«ã©ã ã«çµ±å (Mastodon)
- DMã«ã©ã å»æ¢ (ã¡ãã¥ã¼ããè¦ãããããªå½¢ã«ããäºå®)
- ããã·ã¥éç¥ã¯Twitterå»æ¢ Mastodonç¶ç¶ (Webhookã®ãã¼ã¿ãåããã¨ãã®Twitterã®å¯¾å¿ã«ãã)
ã¿ãããªæãã§ãããããªæã£ã¦ãã¾ãããæ£ç´ã©ããªããã¯ããã£ã¦ãã¾ããã Account Activity API (webhookã®ãã¤)ãç³è«ãããã¢ã«ã¦ã³ãåçµããã¿ãããªãã¨ããã£ããããã®ã§ããã¾ãTwitterã«é¢ããããããã¾ãããâ¦
Twitterã¯ã¯ã½