Re: [twitter-dev] Simple way to get user timeline?
1. register your app at dev.twitter.com to get your set of keys 2. get a hold of and install the twitter_oauth.php class 3. add in the getConnectionWithAccessToken function (I forget where it's available) 4. make your calls like this... (you will use get instead of post, and make the appropriate request for your statuses) $PMconnection = getConnectionWithAccessToken ($pm_consumer_key,$pm_consumer_secret,$pm_access_token, $pm_access_secret); $PMsuccess = $PMconnection-post('https://api.twitter.com/1/statuses/ update.json', array('status' = $thisTweet)); hope this helps On Sep 1, 2010, at 1:17 AM, quick5pnt0 wrote: Can anyone point me in the right direction? -- 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?hl=en
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
I follow that. I was wondering if the creds needed to be in a session var or not. I'll give it a try! Thank you! On Jul 23, 2010, at 11:00 PM, Abraham Williams wrote: 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.
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
ok. thanks for testing! On Jul 23, 2010, at 4:58 AM, Paul wrote: Hi Paul, Yep, was referring to the snippet. I've just copy/pasted yours, changed keys and callback URL and your code works for me. I'm afraid the only thing I can suggest is to double-check your consumer key/secret, Cheers, - Paul
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
Ok... looks like there are others who received the same exception error when trying to generate an auth url. So, I switched over to Abraham's routine, which worked, and the oauth_token and verifier came back, but sadly, a new exception was thrown in the twitter-async code I was still using to retrieve the key/ secret. Right now I'm trying to use Abraham's twitteroauth to output the same info. Is that possible? I looked at the class source but they are different enough to make it opaque to me. There is no equivalent setToken in twitteroauth. Does anyone know how to get twitteroauth to spill the same beans? I'm so close, and yet so far! for the intrepid, here are the async calls I'm trying to find equivalents for in twitteroauth $twitter-setToken( $_GET[oauth_token] ); $token = $twitter-getAccessToken( array( oauth_verifier = $_GET [oauth_verifier] ) ); var_dump( $token-oauth_token, $token-oauth_token_secret ); thank you Paul G On Jul 22, 2010, at 5:53 PM, Paul wrote: Hi Paul, Is there a way to retrieve the consumer keys for the other Twitter account I own without registering an app? Yep, if you use that script given previously, just login to the other Twitter account instead (with the same consumer key/secret. This will give you a different pair of tokens for the second account. Initialise as in tweeting example with the new token. Basically what you're doing is authorising the same app for both accounts. - Paul
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
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 / bNotice/b: Undefined variable: _SESSION in b/path/twittertest- oauth2.php/b on line b21/bbr / br / bNotice/b: Undefined variable: _SESSION in b/path/twittertest- oauth2.php/b on line b21/bbr / br / bNotice/b: Undefined index: oauth_token in b/path/twitteroauth/ twitteroauth.php/b on line b118/bbr / br / bNotice/b: Undefined index: oauth_token_secret in b/path/ twitteroauth/twitteroauth.php/b on line b118/bbr / 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.
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
thanks for fast-tracking me on this! I imagine I would have been at this several more days without this information. Thank you, thank you... and did I say thank you? :) Regards On Jul 22, 2010, at 1:04 PM, Paul wrote: One off: 1) Login to your company Twitter account. 2) Settings - Connections - Click the link under Developers at bottom right. Takes you to: http://twitter.com/apps 3) Register your app. You can get away with 127.0.0.1 as the callback URL if you're running a local webserver, but it's not so important if you're just doing this as a one off as you can specify callback URL at request time.
Re: [twitter-dev] Twitter oAuth for PHP, some advice needed
one quick followup on this, if I may... The Twitter account I registered the app with provided consumer keys / secrets and I used those keys with the client's access tokens to successfully get and post to the account using OAuth. Great. Many thanks to those who pointed me in the right direction. I actually have two separate Twitter accounts to do status updates for depending on the content I have. Sometimes in immediate succession. Is there a way to retrieve the consumer keys for the other Twitter account I own without registering an app? Thank you Paul G
Re: [twitter-dev] Re: Twitter oAuth for PHP, some advice needed
Paul, If you are referring to the twitter-async example you posted, I have installed that and I'm working with it now. I assume the first time through it's meant to take a detour through a Twitter authorization, then back to the same script in which oauth_token and secret is set... and dumped... Looks like I'm not getting a proper authorize URL, and in fact the script dies at that call. No output. Maybe someone can eyeball what's going wrong. Here's what the stack trace says, followed by the script (the names and places have been changed to protect the innocent) bFatal error/b: Uncaught exception 'EpiOAuthException' in /path/ twitter-async/EpiOAuth.php:397 Stack trace: #0 /path/twitter-async/EpiOAuth.php(367): EpiOAuthException::raise (Object(EpiCurlManager), false) #1 /path/twitter-async/EpiOAuth.php(47): EpiOAuthResponse-gt;__get ('oauth_token') #2 /path/twittertest-oauth2.php(29): EpiOAuth-gt;getAuthorizeUrl (NULL, Array) #3 {main} thrown in b/path/twitter-async/EpiOAuth.php/b on line b397/ bbr / ?php require_once classes/twitter-async/EpiCurl.php; require_once classes/twitter-async/EpiOAuth.php; require_once classes/twitter-async/EpiTwitter.php; define( CONSUMER_KEY, $MY_CONSUMER_KEY ); // actual key used define( CONSUMER_SECRET, $MY_CONSUMER_SECRET ); // actual secret used $twitter = new EpiTwitter( CONSUMER_KEY, CONSUMER_SECRET ); if( isset( $_GET[oauth_token] ) ){ try{ $twitter-setToken( $_GET[oauth_token] ); $token = $twitter-getAccessToken( array( oauth_verifier = $_GET [oauth_verifier] ) ); var_dump( $token-oauth_token, $token-oauth_token_secret ); } catch( Exception $e ) { var_dump( get_class( $e ) ); } }else{ $location = $twitter-getAuthorizeUrl(null,array(oauth_callback = http://www.mydomain.tld/dir/twittertest-oauth2.php )); // same address as this script header(Location: $location); exit; } ? On Jul 22, 2010, at 5:53 PM, Paul wrote: Hi Paul, Is there a way to retrieve the consumer keys for the other Twitter account I own without registering an app? Yep, if you use that script given previously, just login to the other Twitter account instead (with the same consumer key/secret. This will give you a different pair of tokens for the second account. Initialise as in tweeting example with the new token. Basically what you're doing is authorising the same app for both accounts. - Paul