James Lin
James Lin

Reputation: 26528

PHP cron script with twitter (problem with oauth)

I am trying to write an php twitter script which will be run by crontab, what the script does is to get the tweets from 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

Upvotes: 2

Views: 1541

Answers (4)

abraham
abraham

Reputation: 47833

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

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

Upvotes: 3

Jayrox
Jayrox

Reputation: 4375

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.

Upvotes: 1

Gelatin
Gelatin

Reputation: 2413

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

Upvotes: 0

Matchu
Matchu

Reputation: 85784

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.

Upvotes: 1

Related Questions