开发者

PHP cron script with twitter (problem with oauth)

开发者 https://www.devze.com 2023-01-02 02:40 出处:网络
I am trying to write an php twitter script which will be run by crontab, what the script does is to get the tweets f开发者_高级运维rom a dedicated twitter account.

I am trying to write an php twitter script which will be run by crontab, what the script does is to get the tweets f开发者_高级运维rom a dedicated twitter account.

I have looked at some of the php twitter oauth libraries, all of them seem to use redirect to a twitter page to get a token, then goes back to a callback link. In my case I don't want to have any user interaction at all.

Could anyone please tell me what I should do?

Regards

James


Twitter provides a single access token feature on dev.twitter.com designed just for this use.

http://dev.twitter.com/pages/oauth_single_token


You shouldn't need to be using the Twitter API at all. Tweets are public resources, accessible via HTTP.

Here's the official Twitter account's last 10 tweets, available as JSON or XML.


I use oAuth for my Twitter bot. I got the oAuth token by making a web interface and signing it up. I then pass the token with my calls.

I use Abraham's oAuth library: http://twitteroauth.labs.poseurtech.com/connect.php

You can use the example from the library to get the token. Just have it echo the token from the $_SESSION it creates on the callback.


Unless the account is private, you don't need to be authenticated.

Or use OAuth, and authenticate using an admin screen.

We do not currently expire access tokens. You access token will be invalid if a user explicitly rejects your application from their settings or if a Twitter admin suspends your application. If your application is suspended there will be a note on your application page saying that it has been suspended.

http://apiwiki.twitter.com/OAuth-FAQ

0

精彩评论

暂无评论...
验证码 换一张
取 消