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 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题