Re: [twitter-dev] Problem with $connection-get('account/verify_credentials')

2011-05-02 Thread Abraham Williams
You have to perform step 6-7 where you exchange your request token for an
access token.

https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION

You can see an example in callback.php:

https://github.com/abraham/twitteroauth/blob/master/callback.php

Abraham
-
Abraham Williams | InboxQ http://inboxq.com/ | abrah.am
@abraham https://twitter.com/abraham | github.com/abraham | blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.



On Sun, May 1, 2011 at 09:02, JJRAY jjr...@gmail.com wrote:

 I'm a newbie with the Twitter API.  I have no problem sending a user
 from my site to Twitter via the api and receiving authentication.
 Here is the code I use for that, tweaked from Nettus.

 ?php
 // Twitter API Example--Nettuts

 session_start();
 require_once('inc/twitterOAuth.php');

 // make sure you swap these for your own!
 $consumer_key = '* * * *';
 $consumer_secret = '* * *';

 // create some request tokens
 $toa = new TwitterOAuth($consumer_key, $consumer_secret);
 $tokens = $toa-getRequestToken();

 // store it in our session
 $_SESSION['oauth_request_token'] = $tokens['oauth_token'];
 $_SESSION['oauth_request_token_secret'] =
 $tokens['oauth_token_secret'];
 $_SESSION['oauth_state'] = 'SENT';

 // send the user on their way
 header('Location: '.$toa-getAuthorizeURL($tokens['oauth_token']));

 ?

 OK, no problem.  However, I cannot then use the tokens I receive back
 from twitter to make a connection.  Here is the code I am trying to
 use.

 html
 head
 titlePHP test post to Twitter/title
 /head
 body
 table width=70% align=centertrtd
 brbr
 stuff starts here
 brbr

 ?php

 // $val1 = $_GET['ot'];
 // $val2 = $_GET['ov'];

 echo 'step one ...  brbr';

 require_once('inc/twitterOAuth.php');
 require_once('inc/config.php');

 echo 'step two ... brbr';

 // $CONSUMER_KEY = '* * * *';
 // $CONSUMER_SECRET = '* * * *';
 // $OAUTH_TOKEN = '* * * *';
 // $OAUTH_SECRET = '* * * *';

 define(CONSUMER_KEY, * * * );
 define(CONSUMER_SECRET, * * * *);
 define(OAUTH_TOKEN, * *  * *);
 define(OAUTH_SECRET, * * *  *);

 echo 'step three ...brbr';

 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 OAUTH_TOKEN, OAUTH_SECRET);
 $content = $connection-get('account/verify_credentials');

 echo 'step four ...brbr';

 $connection-get('users/show', array('screen_name' =
 $_REQUEST['screen_name']));

 $login_status = Hi .$_SESSION['OAUTH_TOKEN']['screen_name']., are
 you ready to archive?bra href='./clearsessions.php'logout/a;
 $logged_in = TRUE;

 ?
 br
 ?php echo $login_status; ?
 brbr
 stuff ends here.
 /td/tr/table

 /body
 /html

 The page stops loading after  echo 'step three ...brbr';  and
 goes blank.  Anyone have an idea why these two lines do not work--

 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 OAUTH_TOKEN, OAUTH_SECRET);
 $content = $connection-get('account/verify_credentials');

 Is the problem that I am missing a step?  All I got in step 1 was a
 request token but not an access token?

 Thanks,
 Joe

 p.s. Apologies to the mod for sending my cons sec key with the post.
 Not a good idea to post code at in the wee hours, especially a sat
 night.

 --
 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


-- 
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


[twitter-dev] Problem with $connection-get('account/verify_credentials')

2011-05-01 Thread JJRAY
I'm a newbie with the Twitter API.  I have no problem sending a user
from my site to Twitter via the api and receiving authentication.
Here is the code I use for that, tweaked from Nettus.

?php
// Twitter API Example--Nettuts

session_start();
require_once('inc/twitterOAuth.php');

// make sure you swap these for your own!
$consumer_key = '* * * *';
$consumer_secret = '* * *';

// create some request tokens
$toa = new TwitterOAuth($consumer_key, $consumer_secret);
$tokens = $toa-getRequestToken();

// store it in our session
$_SESSION['oauth_request_token'] = $tokens['oauth_token'];
$_SESSION['oauth_request_token_secret'] =
$tokens['oauth_token_secret'];
$_SESSION['oauth_state'] = 'SENT';

// send the user on their way
header('Location: '.$toa-getAuthorizeURL($tokens['oauth_token']));

?

OK, no problem.  However, I cannot then use the tokens I receive back
from twitter to make a connection.  Here is the code I am trying to
use.

html
head
titlePHP test post to Twitter/title
/head
body
table width=70% align=centertrtd
brbr
stuff starts here
brbr

?php

// $val1 = $_GET['ot'];
// $val2 = $_GET['ov'];

echo 'step one ...  brbr';

require_once('inc/twitterOAuth.php');
require_once('inc/config.php');

echo 'step two ... brbr';

// $CONSUMER_KEY = '* * * *';
// $CONSUMER_SECRET = '* * * *';
// $OAUTH_TOKEN = '* * * *';
// $OAUTH_SECRET = '* * * *';

define(CONSUMER_KEY, * * * );
define(CONSUMER_SECRET, * * * *);
define(OAUTH_TOKEN, * *  * *);
define(OAUTH_SECRET, * * *  *);

echo 'step three ...brbr';

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
OAUTH_TOKEN, OAUTH_SECRET);
$content = $connection-get('account/verify_credentials');

echo 'step four ...brbr';

$connection-get('users/show', array('screen_name' =
$_REQUEST['screen_name']));

$login_status = Hi .$_SESSION['OAUTH_TOKEN']['screen_name']., are
you ready to archive?bra href='./clearsessions.php'logout/a;
$logged_in = TRUE;

?
br
?php echo $login_status; ?
brbr
stuff ends here.
/td/tr/table

/body
/html

The page stops loading after  echo 'step three ...brbr';  and
goes blank.  Anyone have an idea why these two lines do not work--

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
OAUTH_TOKEN, OAUTH_SECRET);
$content = $connection-get('account/verify_credentials');

Is the problem that I am missing a step?  All I got in step 1 was a
request token but not an access token?

Thanks,
Joe

p.s. Apologies to the mod for sending my cons sec key with the post.
Not a good idea to post code at in the wee hours, especially a sat
night.

-- 
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