dosf40815 2010-09-06 16:53 采纳率: 100%
浏览 28

PHP Twitter Oauth只是检索提要

So I've been using Twitter PHP LIB for pulling user tweets & followers tweets. OpenAuth seems like overkill for this as I need to get the site itself to register for authentication.

Is there a simple library that I can use? Perhaps a basic Oath if you don't need authentication by the user at all?

Should I simply pull the RSS?=

  • 写回答

1条回答 默认 最新

  • duanmiao6695 2011-01-13 13:39
    关注

    I made my own Twitter OAuth library. It still uses OAuth but the library is very small.

    Also, you still need to register an app for it and get the access token.

    If you want to check it out, here is it: I Just Want to Call Twitter’s API With My Own Account!

    Basically you need the consumer key, the consumer secret, the access token and the access token secret, so you have to register your application at [dev.twitter.com] (http://dev.twitter.com/) using the user you want to authenticate, then you will get the first 2. On the same page, click on "My Access Token" and you will get the last 2.

    Then you can:

    $api = new OAuthDamnit(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
    echo $api->get('http://api.twitter.com/1/statuses/home_timeline.json', array()); 
    

    There are other alternatives such as using PHP's OAuth Extension which I think might be faster, but is is also very simple to use.

    $oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
    $oauth->setToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
    $oauth->fetch('http://api.twitter.com/1/statuses/home_timeline.json');
    echo $oauth->getLastResponse();
    

    Or if you don't want to use OAuth at all, you have Simple Auth Twitter which can act like a basic auth gateway.

    You just have to sign it there and it will give you an API key. You use that as your Twitter password and use http://simpleauthtwitter.heroku.com/api/ as the API endpoint.

    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图