Hello Paul,

In redirect.php the request token (also called temporary credentials) are
one use. After the user returns from twitter.com having authorized the
application they are exchanged for an access token from Twitter which is
long lasting and what you are after.

If the request token is not being saved/retrieved from sessions properly you
can print it and the authenticate URL in redirect.php instead of
automatically redirecting. Copy/paste the authenticate url into a browser
window and authorize the app to access the user account. Then you can
manually put the request token into the quick and dirty code instead of
pulling from a session. Keep in mind that you can only use the request token
once so if you don't print the access token the first time you will have to
do it all again.

Abraham
-------------
Abraham Williams | Hacker Advocate | http://abrah.am
@abraham | http://projects.abrah.am | http://blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.


On Fri, Jul 23, 2010 at 14:23, Paul S Gutches <[email protected]>wrote:

>
>
> Thanks Abraham.
>
> I'm still a bit baffled, but I'm sure the origin is local, haha.
>
> I used your testing routine with the "Sign in to Twitter" dialog to try to
> access the account token and secret for storage.   In your redirect.php
> file, it does look like you are setting session vars in there for the token
> and secret before the redirect to Twitter.
>
> But it also says in your comments that those are temporary credentials.  I
> was confused by that, because it's my understanding they're not supposed to
> expire, which is how they can be used again for future access.   Do I have
> that wrong?   I'm looking for the credentials that developers are storing
> for re-use of their user's Twitter accounts.
>
> Even though your redirect.php file is creating a session for the variables,
> when the callback to the quick and dirty code occurs, the variables are not
> accessible.   I get the below notices.
>
> <br />
> <b>Notice</b>:  Undefined variable: _SESSION in 
> <b>/path/twittertest-oauth2.php</b> on line <b>21</b><br />
> <br />
> <b>Notice</b>:  Undefined variable: _SESSION in 
> <b>/path/twittertest-oauth2.php</b> on line <b>21</b><br />
> <br />
> <b>Notice</b>:  Undefined index:  oauth_token in 
> <b>/path/twitteroauth/twitteroauth.php</b> on line <b>118</b><br />
> <br />
> <b>Notice</b>:  Undefined index:  oauth_token_secret in 
> <b>/path/twitteroauth/twitteroauth.php</b> on line <b>118</b><br />
> array(1) {
>   [" "]=>
>   string(0) ""
> }
>
>
> Any advice for keeping hope alive?  :)
>
> Thanks again
>
> Paul G
>
>
> On Jul 23, 2010, at 1:13 PM, Abraham Williams wrote:
>
> This is quick and dirty and assumes that oauth_token and oauth_token_secret
> are set in a session before you are redirected to twitter.com to authorize
> the application.
>
> $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
> $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
> $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
> var_dump($access_token);
>
> Abraham
> -------------
> Abraham Williams | Hacker Advocate | http://abrah.am
> @abraham | http://projects.abrah.am | http://blog.abrah.am
> This email is: [ ] shareable [x] ask first [ ] private.
>
>
>

Reply via email to