OAuth for PHP Twitter Apps, Part I


#1

Notice: This is a discussion thread for comments about the SitePoint article, OAuth for PHP Twitter Apps, Part I.


For those of you that have already moved your apps to OAuth (as you should have!), how was it? If you missed the deadline, are you planning to update your code soon?


#2

Yes I did. I am just noticing the files are being generated but with no content inside.

I ended visiting the twitter developer site and it actually provides you with your oauth_token and oauth_token_secret to use in your code.

I was able to save these in my script. It's showing up as an authorized app on my twitter account now. However, whenever I am trying to send a status update, the tweets are not showing up. I am not seeing any errors... any ideas on why that is happening?


#3

hi all I wanna know that is twitter give do follow links.....i mean when we put link in the twitter is it no follow or do follow......


#4

Thanks for this tutorial - I was able to start tweeting in about 30 minutes by following the instructions.

One point wasn't clear to me: in Example 3, it wasn't obvious that I'd need to add my consumer_key and consumer_secret in the new TwitterOAuth. You might want to add instructions there to "be sure to drop in your consumer key and secret"...

Thanks again!


#5

Everything went great till I tried using the test tweet script for "Hello World" when I go to the php via the web I just get "Connected as @" and no tweet is posted frowning I'm signed in on Twitter and the App is under my connections.

Edit:
I have just noticed both of my access_token files seem to contain nothing so I guess there is the problem.


#6

Sorry if this is obvious, but I'm confused about the consumer_key and consumer_secret.

We have a twitter app that's run by cron every 15 minutes. We use it to post updates to twitter accounts if something has changed on a site. So there are 6 sites and 6 twitter accounts. our app previously had a config file that had the account login information for all of the accounts in it, and it used a simple twitter lib to login and post tweets if there was new content on the web sites.

My question is - do I need to register an app and generate separate consumer_key and consumer_secret tokens for each of the 6 twitter accounts, or is the registration with twitter something that's tied to our app? If the latter, how do you specify the account to which you want to post?

Just confused about the flow here, when the application is running with no public interface.

Thanks!


#7

I've followed every step in detail. Everything has gone like explained, except there is no tweet showing up... Any idea why ?


#8

By the way, there is a good documentation on php website about oauth module:
http://us.php.net/oauth

It's just much better to use the module than a class. The reason why that class (in the article) became somewhat popular is because at the time it was written the php's own oauth module was still in alpha, so there was no existing classes for oauth then. Now than php's own oauth module is version 1 (still dev, but stable), there is no reason to use anything else.


#9

I've been using pecl OAuth library for over 6 months now. I find it much easier to use then a class, it's also universal and can be used to access many other OAuth based sites.
There is a nice tuturial written by Rasmus Lerdorf (creator of php and he also one of the authors of this pecl class)
Read it here: http://toys.lerdorf.com/archives/50-Using-pecloauth-to-post-to-Twitter.html

Enjoy


#10

@Ernie1

Thank you Ernie1, but still don't work !!


#11

edit php.ini
comment out extension=php_curl.dll

restart apache


#12

: / I cant find the 7 digit pin


#13

I followed this article and found errors that others did as well. Here's my findings :-

Check paths for required files. As @themasterbrewer said, they have an extra folder reference.

After generating the pin and trying to validate it immediately afterwards, I realised the access_token and access_token_secret files were blank, resulting in the blank "Connected as @" issue, and no tweet sent. As @sgtquezada said, if this is also happening to u, check dev.twitter.com and u shud get these values from the application settings.

No reason not to store these values in the php file that is going to auto-tweet for you rather than having them in separate files and reading them in with file_get_contents.

Hope this helps someone.


#14

Hey there -

I am noticing the authorize URL is not correct since the oauth_token parameter is empty. I get an error when trying to navigate to this link.

====

Woah there!

This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.

Can anybody tell me why the request_token and request_token_secret files are empty?


#15

I cant find


#16

nofollow


#17

I cant find the 7 digit pin


#18

Some people are having problems with Twitter not giving them a PIN.

If this is you please check that your app has been registered with an "Application Type" of "CLIENT".


#19

Thanks for a great tutorial, makes it very simple!

I did encounter one problem though - you entered your twitteroauth.php URL as follows in a few places:

require_once('twitteroauth/twitteroauth/twitteroauth.php');

This caused me a few PHP errors as the URL for me was actually twitteroauth/twitteroauth.php - your URL has one too many "twitteroauth"s!


#20

FYI:
Compromising Twitter's OAuth security system

Sadly, Twitter's extremely poor implementation of the OAuth standard offers a textbook example of how to do it wrong. This article will explore some of the problems with Twitter's OAuth implementation and some potential pitfalls inherent to the standard.