[twitter-dev] Is it this simple - OAUTH PHP Transition from Basic Authentication
Using Abraham Williams twitteroauth library I used this base code to post Twitter. Is it that simple? Of course my app code is actually longer. I'm writing an app that takes new news stories posted to our web site and automatically tweets them. A question though: What's the best way to handle $access_key which is the oauth_token and $access_secret which is the oauth_token_secret? I've read they should not be readable in your php code. ?php $consumer_key = 12345; $consumer_secret = 6789; $access_key = 12345; $access_secret = 6789; require_once('twitteroauth/twitteroauth.php'); $connection = new TwitterOAuth ($consumer_key ,$consumer_secret , $access_key , $access_secret ); $connection-post('statuses/update', array('status' = my tweet)); ?
[twitter-dev] New app for every Twitter account?
My company has several news sites and each has one or more Twitter accounts depending on the topic. I've created a new app using OAuth and PHP to post our news stories automatically as they are published. Previously with basic authentication I would just pass the username and password etc. to get the story posted. But now I'm wondering, do I need to create a new app for every Twitter account we have? Or can I post to our accounts with the one app I created with its keys and tokens? And if I can use just the one app, how do I post to the other accounts? The app was created on our primary Twitter account. Thanks Marc PS I already have the OAuth and PHP code working for our primary Twiter account.
[twitter-dev] Re: New app for every Twitter account?
Hi Taylor, Ok, but how do you get an access token/access token secret for the other account without creating a new app? On Aug 11, 3:49 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Hi Marc, In this case, instead of using the username/password of a different account while making a request, you would use an access token/access token secret belonging to a different account. You don't need to create separate applications for each account, but you need to authorize the application to act on behalf of each account. If you don't want to implement the OAuth flow to acquire access tokens in your application, you can use another application or library (such as my OAuth Dancer athttp://github.com/episod/oauth-dancer) to secure the access tokens, then port them over to your proper application. Taylor On Wed, Aug 11, 2010 at 12:37 PM, Skygazer marc.bouc...@gmail.com wrote: My company has several news sites and each has one or more Twitter accounts depending on the topic. I've created a new app using OAuth and PHP to post our news stories automatically as they are published. Previously with basic authentication I would just pass the username and password etc. to get the story posted. But now I'm wondering, do I need to create a new app for every Twitter account we have? Or can I post to our accounts with the one app I created with its keys and tokens? And if I can use just the one app, how do I post to the other accounts? The app was created on our primary Twitter account. Thanks Marc PS I already have the OAuth and PHP code working for our primary Twiter account.
[twitter-dev] Re: New app for every Twitter account?
That makes sense to me but that's not supported at this time from my understanding. On Aug 11, 5:04 pm, Jacky jaga...@gmail.com wrote: No he means each source is a user and has its own account, and authorizes the single app for separate access tokens.. However, my question is, is not having aliases a btter solution for this? In other words, on user having several aliases, each alias being permitted to get separate access tokens for the same app? Regards, Shob On Aug 11, 1:58 pm, Skygazer marc.bouc...@gmail.com wrote: Hi Taylor, Ok, but how do you get an access token/access token secret for the other account without creating a new app? On Aug 11, 3:49 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Hi Marc, In this case, instead of using the username/password of a different account while making a request, you would use an access token/access token secret belonging to a different account. You don't need to create separate applications for each account, but you need to authorize the application to act on behalf of each account. If you don't want to implement the OAuth flow to acquire access tokens in your application, you can use another application or library (such as my OAuth Dancer athttp://github.com/episod/oauth-dancer) to secure the access tokens, then port them over to your proper application. Taylor On Wed, Aug 11, 2010 at 12:37 PM, Skygazer marc.bouc...@gmail.com wrote: My company has several news sites and each has one or more Twitter accounts depending on the topic. I've created a new app using OAuth and PHP to post our news stories automatically as they are published. Previously with basic authentication I would just pass the username and password etc. to get the story posted. But now I'm wondering, do I need to create a new app for every Twitter account we have? Or can I post to our accounts with the one app I created with its keys and tokens? And if I can use just the one app, how do I post to the other accounts? The app was created on our primary Twitter account. Thanks Marc PS I already have the OAuth and PHP code working for our primary Twiter account.
[twitter-dev] Re: New app for every Twitter account?
Ok, I'll give it a try. Thanks. On Aug 11, 5:02 pm, Tom van der Woerdt i...@tvdw.eu wrote: Hi Marc, You can do this using the OAuth authentication flow which you can find athttp://dev.twitter.com/pages/auth#intro This may seem very much complicated for a simple application with only a few users (and static keys), and I agree. However, unless there is some service on the internet which simply allows you to get some keys in exchange for your username/password (and I do not know any), you will have to use this. Tom On 8/11/10 10:58 PM, Skygazer wrote: Hi Taylor, Ok, but how do you get an access token/access token secret for the other account without creating a new app? On Aug 11, 3:49 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Hi Marc, In this case, instead of using the username/password of a different account while making a request, you would use an access token/access token secret belonging to a different account. You don't need to create separate applications for each account, but you need to authorize the application to act on behalf of each account. If you don't want to implement the OAuth flow to acquire access tokens in your application, you can use another application or library (such as my OAuth Dancer athttp://github.com/episod/oauth-dancer) to secure the access tokens, then port them over to your proper application. Taylor On Wed, Aug 11, 2010 at 12:37 PM, Skygazer marc.bouc...@gmail.com wrote: My company has several news sites and each has one or more Twitter accounts depending on the topic. I've created a new app using OAuth and PHP to post our news stories automatically as they are published. Previously with basic authentication I would just pass the username and password etc. to get the story posted. But now I'm wondering, do I need to create a new app for every Twitter account we have? Or can I post to our accounts with the one app I created with its keys and tokens? And if I can use just the one app, how do I post to the other accounts? The app was created on our primary Twitter account. Thanks Marc PS I already have the OAuth and PHP code working for our primary Twiter account.
[twitter-dev] Re: Twitter oAuth for PHP, some advice needed
Hi everyone, I'm in the same boat as Paul G. My company publishes updates to Twitter whenever we post a new story. To date our code using basic authentication was working great. Now we're switching over to OAUTH using Abraham Williams library. I setup an app on Twitter's development site, got my keys and tokens and tried using the PHP twitteroauth library, but on my test server I can't even get the example to work. I get the Could not connect to Twitter. Refresh the page or try again later message. I've got the library running on my Mac Pro with Apache running on a port-forward. I'll note that when I created the app I used application type: browser and callback url: blank Any help would be appreciated. Code always welcome :-) Marc On Jul 22, 2:09 pm, Paul G p...@taosinteractive.com wrote: Hi Everyone. I've been puzzling overOAuthfor some time now with little insight into how to apply it to my situation. If someone could nudge me in the right direction I'd be most grateful. What I am doing now is very simple. Whenever my company publishes new content to it's websites, the companyTwitteraccount is updated to reflect it. This is not an application that is open to public use. It doesn't require any browser-based login boxes or http redirects as part of the process. In fact, such a requirement would prevent the function of my current routine. EXAMPLE: (synopsis) require classes/Twitter.class.php; $PMTtweet = newTwitter($twitterunamePMT, $twitterpwordPMT); $PMTsuccess = $PMTtweet-update($thisTweet); My questions are: 1. Do I need to upgrade toOAuth? 2. If I need to upgrade toOAuth, can it be done in such a way as to work without browser login and redirect requirements? (as per example) 3. If 2 is true, any tutorials that match that situation you can point me to? 4. If 1 2, where/how would I acquire the tokens necessary to useOAuth? Apologies for the basic questions. I really did make an effort to ferret out the answers but all the examples I encountered were much more complex than my situation requires. Thanks Paul G
[twitter-dev] Re: Twitter oAuth for PHP, some advice needed
I got my code working well enough to forge ahead on my own thanks to the examples on Abraham's github wiki page http://wiki.github.com/abraham/twitteroauth/links Marc On Aug 10, 12:25 pm, Skygazer marc.bouc...@gmail.com wrote: Hi everyone, I'm in the same boat as Paul G. My company publishes updates to Twitter whenever we post a new story. To date our code using basic authentication was working great. Now we're switching over toOAUTH using Abraham Williams library. I setup an app on Twitter's development site, got my keys and tokens and tried using thePHP twitteroauth library, but on my test server I can't even get the example to work. I get the Could not connect to Twitter. Refresh the page or try again later message. I've got the library running on my Mac Pro with Apache running on a port-forward. I'll note that when I created the app I used application type: browser and callback url: blank Any help would be appreciated. Code always welcome :-) Marc On Jul 22, 2:09 pm, Paul G p...@taosinteractive.com wrote: Hi Everyone. I've been puzzling overOAuthfor some time now with little insight into how to apply it to my situation. If someone could nudge me in the right direction I'd be most grateful. What I am doing now is very simple. Whenever my company publishes new content to it's websites, the companyTwitteraccount is updated to reflect it. This is not an application that is open to public use. It doesn't require any browser-based login boxes or http redirects as part of the process. In fact, such a requirement would prevent the function of my current routine. EXAMPLE: (synopsis) require classes/Twitter.class.php; $PMTtweet = newTwitter($twitterunamePMT, $twitterpwordPMT); $PMTsuccess = $PMTtweet-update($thisTweet); My questions are: 1. Do I need to upgrade toOAuth? 2. If I need to upgrade toOAuth, can it be done in such a way as to work without browser login and redirect requirements? (as per example) 3. If 2 is true, any tutorials that match that situation you can point me to? 4. If 1 2, where/how would I acquire the tokens necessary to useOAuth? Apologies for the basic questions. I really did make an effort to ferret out the answers but all the examples I encountered were much more complex than my situation requires. Thanks Paul G
[twitter-dev] Re: Simple oAuth php cURL token_request example not working
I believe you need to change your Set url from: $url = http://api.twitter.com/oauth/request_token;; to $url = http://twitter.com/oauth/request_token;; Marc On Jul 20, 3:50 pm, Derrick derrick.egersdor...@gmail.com wrote: The code below simply gives me Failed to validateoauthsignature and token : really battling to spot the problem here. // Set url $url = http://api.twitter.com/oauth/request_token;; // Params to pass to twitter and create signature $params['oauth_callback'] = http://localhost/twitter/tweet/;; $params['oauth_consumer_key'] = $this-consumerKey; $params['oauth_nonce'] = SHA1(time()); $params['oauth_timestamp'] = time(); $params['oauth_signature_method'] = $this-signatureMethod; $params['oauth_version'] = $this-version; ksort($params); // Signing // Concatenating $concatenatedParams = ''; foreach($params as $k = $v) { $k = urlencode($k); $v = urlencode($v); $concatenatedParams .= {$k}={$v}; } $concatenatedParams = urlencode(substr($concatenatedParams, 0,-1)); $signatureBaseString = POST.urlencode($url).. $concatenatedParams; $params['oauth_signature'] = base64_encode( hash_hmac('sha1', $signatureBaseString, $this- secret., true) ); // Do cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); $exec = curl_exec ($ch); $info = curl_getinfo($ch); curl_close ($ch); print $exec;