Hello,

(note: this question might actually be more a general programming
question rather than specific to Twitter)
I have been looking at a few PHP libraries to use OAuth with Twitter
(thanks to Abraham and Jason amongst others) and noticed that most (if
not all) of them have a constructor more or less like that:
function __construct($consumer_key, $consumer_secret, $oauth_token =
NULL, $oauth_token_secret = NULL)
called with 2 or 4 arguments depending on where in the OAuth process
we are. (access token already known or not)

That usually means that the status of the OAuth process is to be
managed in the controllers when creating the object.
If you take the example from Abraham's code:
http://github.com/abraham/twitteroauth/blob/6b28e9e689d44a569576f726777e9986fa67729c/example/index.php
there's a lot of session variables management (granted, this code is
provided as an example and advertised as "not for production"...)

Basically, I feel that I'd rather do something like:

$twitter = new TwitterOAuth();
$twitter->getPublicTimeline();
if ($twitter->isAuthenticated()) { $twitter->getFriendsTimeline();}
etc.

with the logic of if the access token is known being handled by the
class itself.

Since all the libraries I have seen didn't go this way (and were
written by people who most probably know what they're doing a lot more
than I do), I am wondering if I make any sense.

Thanks for your help,

Tim

Reply via email to