Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-05-01 Thread Lil Peck
OK guys, I am really tickled to have finally worked out a reasonable
understanding of how to use Abraham's Twitter Oauth for making
automated status updates. You're right, it is easy. And it's fun!
Thank you, thank you, Abraham, for making this available!!!

For anyone else who may be struggling with how to move from PHP
curl/basic authentication to Oauth, here's a quick tip:

Focus on Abraham's test.php file. Register callback.php as your app,
but load test.php in your browser. COMMENT OUT everything in the
script that doesn't interest you, because it will create/alter/delete
everything in your twitter account. (I had to comment stuff out
because I was unable to create a test account.) Edit config.php

At Twitter.com go to your apps listing and retrieve your consumer key
and consumer secret. Click on the My Access Token button to get your
access token and access secret.

I'll paste a very stripped down version of test.php below, in case
this is helpful to anyone. After edited with your keys and tokens,
then loaded in a browser, this will post status updates.

?php
/**
 * @file
 *
 */

/* Load required lib files. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');


session_start();
$_SESSION['access_token'] = 'YOURACCESSTOKENSTRING'; // store session data
session_start();
$_SESSION['oauth_token_secret'] = 'YOURACCESSTOKENSECRET'; // store session data



/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) ||
empty($_SESSION['access_token']['oauth_token']) ||
empty($_SESSION['access_token']['oauth_token_secret'])) {
header('Location: ./clearsessions.php');
}
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];

/* Create a TwitterOauth object with consumer/user tokens. */

function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$oauth_token, $oauth_token_secret);
  return $connection;
}


$connection = getConnectionWithAccessToken(YOURACCESSTOKENSTRING,
YOURACCESSTOKENSTRING);



/* Get logged in user to help with tests. */
$user = $connection-get('account/verify_credentials');

$active = TRUE;


function twitteroauth_row($method, $response, $http_code, $parameters = '') {

  if (!is_string($response)) {
$response = print_r($response, TRUE);
  }
  if (!is_string($parameters)) {
$parameters = print_r($parameters, TRUE);
  }


}



/* statuses/update */

$parameters = array('status' = 'YOUR STATUS UPDATE HERE MUST BE UNIQUE');
$status = $connection-post('statuses/update', $parameters);
twitteroauth_row('statuses/update', $status, $connection-http_code,
$parameters);


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-05-01 Thread Lil Peck
Emboldened by my success with Abraham's library, I moved along to
Scott Desapio's for Classic ASP! Succeeded in using it to post status
update via script w/o the Oauth dosey-do. Yay! Thanks very, very much
to Scott for doing all of this great work of clearing a path through
the wilderness for the rest of us. Those of you who are advanced like
Scott and Abraham may be unable to understand why it is that we mere
mortals have a difficult time adapting to Oauth for Twitter.

I'll share what I did to help others who may be as worried about Oauth
as I was. This is not a finished, polished app, it is merely an
exercise in simplifying everything to get the most basic results just
as a start. Here's a quick rundown:

After uploading Desapio's files
(http://scottdesapio.com/VBScriptOAuth/), search and replace
127.0.0.1 with your domain name, assuming you're using a hosting
company rather than your own PC.

To be able to make status updates via web script programmatically
without logging in, etc.,
go to this file oauth/cLibOAuth.RequestURL.asp

and look for
Dim strSecret : strSecret = _
m_strConsumerSecret_
m_strTokenSecret

Replace m_strConsumerSecret with the string that is your consumer secret.
Replace m_strTokenSecret with the string that is your oauth_token_secret.

Next go to update_status.asp and look for
' setup oAuth object

'''
objOAuth.ConsumerKey = OAUTH_EXAMPLE_CONSUMER_KEY
objOAuth.ConsumerSecret = OAUTH_EXAMPLE_CONSUMER_SECRET
objOAuth.EndPoint = TWITTER_OAUTH_URL_UPDATE_STATUS
objOAuth.Parameters.Add in_reply_to, strReplyTo
objOAuth.Parameters.Add in_reply_to_status_id, intReplyID
objOAuth.Parameters.Add oauth_token, Session(OAUTH_TOKEN)
objOAuth.Parameters.Add status, strStatus
objOAuth.RequestMethod = OAUTH_REQUEST_METHOD_POST



Replace as follows:
' setup oAuth object

'''
objOAuth.ConsumerKey = YOUR-CONSUMER-KEY-HERE
objOAuth.ConsumerSecret = YOUR-CONSUMER-SECRET-HERE
objOAuth.EndPoint = TWITTER_OAUTH_URL_UPDATE_STATUS
'objOAuth.Parameters.Add in_reply_to, strReplyTo COMMENT OUT UNLESS
THIS IS WHAT YOU WANT TO DO
'objOAuth.Parameters.Add in_reply_to_status_id, intReplyID COMMENT OUT
'objOAuth.Parameters.Add oauth_token, Session(OAUTH_TOKEN)
commented out and replaced as below with oauth token from twitter app
settings
objOAuth.Parameters.Add oauth_token, 
YOUR-APP-OAUTH-TOKEN-HERE
objOAuth.Parameters.Add oauth_token_secret,
YOUR-APP-OAUTH-TOKEN-SECRET-HERE
objOAuth.Parameters.Add status, strStatus
objOAuth.RequestMethod = OAUTH_REQUEST_METHOD_POST


Find the line that says
Dim strStatus : strStatus = Request.Form(post)
and replace as follows:
Dim strStatus : strStatus = YOUR UNIQUE STATUS UPDATE HERE

Comment out the following lines:
'Dim intReplyId : intReplyId = Request.Form(replyId)
'Dim strReplyTo : strReplyTo = Request.Form(replyTo)

Comment out:
'If objOAuth.LoggedIn Then

Comment out:
'Else
'Response.Status = RESPONSE_STATUS_403
'End If


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Raffi Krikorian
i'm confused - why not use an oauth php library if using php?

On Fri, Apr 30, 2010 at 4:00 PM, Lil Peck lilp...@gmail.com wrote:

 If Twitter doesn't come up with a way for those of us who use PHP curl
 or ASP xhttp to automatically post status updates from our sites, then
 this could be a nice opportunity for someone to create a new web
 service to fill that gap. Code a service to which we post our updates
 that will in turn submit them to Twitter for us.

 Does anyone know of a service that does that now?




-- 
Raffi Krikorian
Twitter Platform Team
http://twitter.com/raffi


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Abraham Williams
To post automatically from your site in PHP is very easy.

1) Get TwitterOAuth: http://github.com/abraham/twitteroauth

2) Follow these instructions:
http://dev.twitter.com/pages/oauth_single_token

Abraham

On Fri, Apr 30, 2010 at 16:00, Lil Peck lilp...@gmail.com wrote:

 If Twitter doesn't come up with a way for those of us who use PHP curl
 or ASP xhttp to automatically post status updates from our sites, then
 this could be a nice opportunity for someone to create a new web
 service to fill that gap. Code a service to which we post our updates
 that will in turn submit them to Twitter for us.

 Does anyone know of a service that does that now?




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


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread John Jawed
http://svn.php.net/viewvc/pecl/oauth/trunk/examples/twitter/

On Fri, Apr 30, 2010 at 4:00 PM, Lil Peck lilp...@gmail.com wrote:
 If Twitter doesn't come up with a way for those of us who use PHP curl
 or ASP xhttp to automatically post status updates from our sites, then
 this could be a nice opportunity for someone to create a new web
 service to fill that gap. Code a service to which we post our updates
 that will in turn submit them to Twitter for us.

 Does anyone know of a service that does that now?



Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Lil Peck
On Fri, Apr 30, 2010 at 8:52 PM, John Jawed johnja...@gmail.com wrote:
 http://svn.php.net/viewvc/pecl/oauth/trunk/examples/twitter/


John,

Per your suggestion, I'm trying those files out also. However I get this error
Fatal error: Class 'OAuth' not found

so, which set of files do I need to upload? Or, is this something that
requires root server access?

Lil


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Lil Peck
On Fri, Apr 30, 2010 at 8:38 PM, Lil Peck lilp...@gmail.com wrote:

 I have downloaded and installed your files. In which file on which
 line should I paste the code:

 function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 $oauth_token, $oauth_token_secret);
  return $connection;
 }

 $connection = getConnectionWithAccessToken(abcdefg, hijklmnop);
 $content = $connection-get(statuses/home_timeline);



Working on Abraham's example:

OK, that code above is actually supposed to replace line 20 on callback.php?
And the strings (abcdefg, hijklmnop) are to be replaced with the
tokens found on the tokens tab on twitter.com at my_token?


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Lil Peck
On Fri, Apr 30, 2010 at 8:38 PM, Lil Peck lilp...@gmail.com wrote:

 I have downloaded and installed your files. In which file on which
 line should I paste the code:

 function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 $oauth_token, $oauth_token_secret);
  return $connection;
 }

 $connection = getConnectionWithAccessToken(abcdefg, hijklmnop);
 $content = $connection-get(statuses/home_timeline);




OK one thing I see that I overlooked before on the twitter myapps area
was the tab that gives the consumer key and consumer secret.


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Lil Peck

 function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 $oauth_token, $oauth_token_secret);
  return $connection;
 }

 $connection = getConnectionWithAccessToken(abcdefg, hijklmnop);
 $content = $connection-get(statuses/home_timeline);



I've been experimenting with Abraham's library and have successfully
posted a status update via the test.php page.

However, I still need to know where the code above for One Access
Token should be pasted, and what lines should be commented out. I've
been trying to guess but not getting it right.

Lil


Re: [twitter-dev] App Opportunity: OAuthcalypse

2010-04-30 Thread Lil Peck
On Fri, Apr 30, 2010 at 11:26 PM, Lil Peck lilp...@gmail.com wrote:

 function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
 $oauth_token, $oauth_token_secret);
  return $connection;
 }

 $connection = getConnectionWithAccessToken(abcdefg, hijklmnop);
 $content = $connection-get(statuses/home_timeline);




OhMyGosh I think I'm getting the hang of it!
Lil