简体   繁体   English

Twitter API中的用户流

[英]user stream in twitter api

I want to read my own twit in a litte localhost application in js + php. 我想在js + php的本地主机应用程序中读取自己的twit。
I know how to read the json in api.twitter.com/1/statuses/user_timeline.json?screen_name=myName but due to the limit rate I need to make a User Stream ( https://dev.twitter.com/docs/streaming-api/user-streams ) 我知道如何在api.twitter.com/1/statuses/user_timeline.json?screen_name=myName中读取json,但是由于限制速率,我需要创建一个用户流( https://dev.twitter.com/docs / streaming-api / user-streams

I have my 4 keys by create a dev account : 我通过创建开发人员帐户拥有4个密钥:

'consumer_key' => '*****',
'consumer_secret' => '*****',
'user_token' => '*******',
'user_secret' => '******',

So I try with this https://github.com/themattharris/tmhOAuth/blob/master/examples/userstream.php 所以我尝试使用这个https://github.com/themattharris/tmhOAuth/blob/master/examples/userstream.php

  1. download the lib 下载库
  2. run my MAMP (or WAMP or LAMP) 运行我的MAMP(或WAMP或LAMP)
  3. open the example, put my key 打开例子,把我的钥匙
  4. go to the page 转到页面
  5. and nothing. 没事了。 except the browser loader. 浏览器加载程序除外。

Why this hapeens? 为什么会这样?

  1. is it due to localhost ? 是因为localhost吗?
  2. or no params ? 还是没有参数?
  3. or new twitter restriction ? 还是新的Twitter限制?

Streaming API is not right tool for litte application You are better off with plain REST API. Streaming API不是适用于小型应用程序的工具,使用普通的REST API更好。

Streaming API application is not supposed to be run in browser; 流API应用程序不应在浏览器中运行; don't forget to set_time_limit(0) and start your .php script in comandline - where it will run forever (you should save tweets in database so your normal browser scripts could display them) 不要忘了set_time_limit(0)并以comandline启动.php脚本-它将在其中永久运行(您应该将tweet保存在数据库中,以便普通的浏览器脚本可以显示它们)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM