Implementing OAuth , PHP

26 views
Skip to first unread message

Tweet Closer

unread,
Feb 25, 2011, 8:11:19 AM2/25/11
to Twitter Development Talk
Guys, I'm getting very confused moving to OAuth.

I've read and made notes on http://hueniverse.com/oauth/guide/ and
http://www.snipe.net/2009/07/writing-your-first-twitter-application-with-oauth/
but I'm missing something that must be obvious to everyone else. I'm
using Tijs Verkoyen's Twitter class.

I want to run http://classes.verkoyen.eu/twitter_oauth/docs#statusesusertimeline
to get a user's latest tweets.

The example code says:

<?php
// require
require_once 'twitter.php';

// create instance
$twitter = new Twitter('<your-consumer-key>', '<your-consumer-
secret>');

// set tokens
$twitter->setOAuthToken('<your-token>');
$twitter->setOAuthTokenSecret('<your-token-secret>');

// get users timeline
$response = $twitter->statusesUserTimeline();

// output
var_dump($response);
?>

but that just looks like you provide everything .. two pairs of
authentication codes. Is that right? So my consumer key and secret
come from registering the app with twitter, and the token and token
secret come from when you authorize the app to use your Twitter
account, right, and they come back as GET parameters. I did that
probably a few months ago and can't see to re-do that process, is that
the problem? If I try to re-run that I get "Woah there! This page is
no longer valid. It looks like someone already used the token
information you provided. Please return to the site that sent you to
this page and try again … it was probably an honest mistake."

Anyway, I'm trying the code above and getting back Invalid / expired
Token

Gizza clue :-)

Cheers
J

Peter Denton

unread,
Feb 25, 2011, 12:55:05 PM2/25/11
to twitter-deve...@googlegroups.com
if you are not too far down the road with Tiis Verkoyen's class, I can send you an example using Abraham's oAuth library which will show you how to do this.
I am guessing that you are looking at examples showing you a user coming, authenticating, and then invoking actions on the users behalf. However, what you want to do is to create an app, get that app's tokens, and do an action server side.


--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk



Tweet Closer

unread,
Feb 25, 2011, 3:07:57 PM2/25/11
to twitter-deve...@googlegroups.com
On Fri, Feb 25, 2011 at 5:55 PM, Peter Denton <peterm...@gmail.com> wrote:
if you are not too far down the road with Tiis Verkoyen's class, I can send you an example using Abraham's oAuth library which will show you how to do this.
I am guessing that you are looking at examples showing you a user coming, authenticating, and then invoking actions on the users behalf. However, what you want to do is to create an app, get that app's tokens, and do an action server side

Yes, you're right Peter, I don't think I made that clear, thanks. I have an app that wants to access Twitter, that's basically it, and of course it was working with basic auth.

Anyway, yes if you have other code, I've butted up against the Verkoyen wall three times now and haven't managed to push through.

Cheers
J

Tweet Closer

unread,
Mar 3, 2011, 3:59:07 AM3/3/11
to Twitter Development Talk


On Feb 25, 5:55 pm, Peter Denton <petermden...@gmail.com> wrote:
> if you are not too far down the road with Tiis Verkoyen's class, I can send
> you an example using Abraham's oAuth library which will show you how to do
> this.

OK, ta, I've downloaded that class, I'll have a play

J
Reply all
Reply to author
Forward
0 new messages