OAuth for PHP Twitter Apps, Part I

I have that error in the register.php file

Fatal error: Call to undefined function curl_init() in C:\wamp\www\ witteroauth\ witteroauth.php on line 199

I have that error in the register.php file

Fatal error: Call to undefined function curl_init() in C:\wamp\www\ witteroauth\ witteroauth.php on line 199

@sgtquezada: have you put your consumer key and secret in the script?

Can this api be used for checking and replacing twitter usernames on existing account?

Where do we find ‘$credentials = $oauth->get(“account/verify_credentials”);’ in the excerpt?

I get response of ‘Connected as @’

@friolator: you would need to generate separate tokens for each account, unfortunately

Hi ,

This is a great tutorial , I used it a while back, followed the instructions and was tweeting in a few minutes. The facebook app i used this with is still tweeting away like a champion.

This evening I sat down to wire up a new app followed the instructions as before got through to twitter and got my pin number but this is where things stop working.

The Validate.php no longer works for me. I have tried and tried, double checked and double checked. I cannot get the thing to validate the pin and create the two files.

The timing between hitting the register and validate is less than 10 secs.

I read through some of the comments and one person suggested using OAuth from PHP what a melt that was. So its prompted me to come back here and ask has Twitter changed anything recently that has broke this.

Any feedback is welcomed

I solved this a few minutes after posting thanks to the person who commented before me.

It was not quite clear in your post up it lead me to resolving the issue.

Twitter has indeed made some changes it seems you no longer need the pin

If you browse to http://dev.twitter.com

you should be able to find your registered app, if you click on your app name the page refreshes and on the right hand side you will see “My Access Token”

In there you will find

Access Token (oauth_token)
dfdsfsdfdskfsdkjfkjdshf

Access Token Secret (oauth_token_secret)
dsfksdhfjksdhfjkhdsjkf

These are the two files that would have been created using the pin, so all you need to do is grab these and include where you need in your file. Once i took these and added it to the test file , first try it tweeted out.

Rocking again,

Thanks for the tutorial and walk through with the original it was a great help. I hope this post helps someone else who walks in to the same situation as myself.

I would presume this is to keep those accesstoken values more secure, eg outside the public_html folder. If your php file that’s going to tweet is already outside the public folder, then by all means, put those values straight in :slight_smile:

I had no trouble setting this up within a very short time, right through to getting the Hello World tweet. You do, of course, have to check the included file paths, but that should be common sense :slight_smile:

Thanks very much for the tutorial!

in twitter (dev.twitter.com etc) you can get all the tokens for that account. That’s how you do it in the twitter-app in word-press.

Question:
Is it good practice to store these tokens in a database, or is a secure place outside www-root better?

Trond

Hello Raj,
Thanks a lot!, this is really very very handy tutorial. it is still valid event after changing the Twitter ID format.

but i have one question?? why we retrieve Access Token and Access Token Secret via register.php and validate.php, bcoz it is already there when we register new application.

Thank you for this tutorial! I got the script working fairly easily. But now I want to modify it and display my latest tweets.

On one of my sites I parse an RSS feed of my tweets with the php fopen function but on another site the same script fails (failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request ). I figure if I have an authorized request I should be able to get the tweets using http://api.twitter.com/version/statuses/user_timeline.rss but I have no idea how to implement this and store it as a var which I can parse.

Any help or likes to tutorials appreciated.

I am aware of javascript solutions, but it needs to be PHP so Google bots read it as HTML content.