Log into Pligg using Twitter OAuth

Aug

08
2009

I am doing it! I am releasing my Pligg mod to get Twitter login working. I have stuck to the smarty way where possible (excluding errors :p). It is my first hack so bear with me. There are instructions included in the attached zip file but I would really suggest you read the following:

OAuth getting started guide
Twitter OAuth FAQ

Credits to Jaisen Mathai for his Twitter-async classes.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

About eamonn

View all posts by: eamonn

  • renzo

    Where is the DB.php file?

  • Geoserv

    I am getting a DB error.

    Fatal error: Call to undefined method DB_Error::fetchRow()

    Any ideas what that means? The database info I added is correct.

  • Geoserv

    Sorry to repost so fast, but, it seems as though the issue is we havent added any tables to the database.

    The function that is causing the error is this:

    {
    $query = ‘select twitter_user_name, pligg_user_name, pligg_password FROM twitter_user_map where twitter_user_name = ?’;
    $result = $DB->query($query, $twitterUserName);
    $userDetails = $result->fetchRow(DB_FETCHMODE_OBJECT);
    if ($result->numRows() == 0) {
    createAccount($DB,$twitterUserName, 0, $twitterUserName);
    } else {
    redirectToLogin($userDetails->pligg_user_name, $userDetails->pligg_password);
    }
    }

    the error is coming because the file can’t find the tables being referenced in the above function.

    Can you tell us what the table has in the database so we can manually add it.

    Thanks.

  • http://eamonnfaherty.co.uk eamonn

    Sorry! :)

    I forgot to include the db patch:

    CREATE TABLE IF NOT EXISTS `twitter_user_map` (
      `twitter_user_name` varchar(255) NOT NULL,
      `pligg_user_name` varchar(32) NOT NULL,
      `pligg_password` varchar(255) NOT NULL,
      PRIMARY KEY  (`twitter_user_name`),
      UNIQUE KEY `pligg_user_name` (`pligg_user_name`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    

    I will update the zip file.

  • booger

    How exactly your plugin works? i´ve done all modifications but after i get the token back the page stays blank on the confirm.php and doesn´t go anywhere. no errors, no users on the database or logged on to the site.
    by the way, u´ve forgot to include the DB.php file, so i´ve create one with the settings.

    and changed the line:

    @$DB = DB::connect(‘mysqli://USER:PASS@localhost/DB’);

    to

    @$DB = DB::connect(‘mysqli://$username_mysql:$password_mysql@$hostname_mysql/$database_mysql’);

  • http://eamonnfaherty.co.uk eamonn

    Hey booger,

    I left the include for DB.php in by mistake. You should delete the one you created and update the version you have with this one.

    If you get stuck with this one pm me your site and i will have a look.

    Eamonn

  • http://www.pliggs.com Geoserv

    I uploaded your updated zip file, amde the neccessary changes, but I get a blank index.php screen when I click the “Twitter user?” link. The address bar shows a token but thats it.

    Any ideas?

  • http://eamonnfaherty.co.uk eamonn

    Could you send me a link to your environment please? How is your php.ini file configured to show errors? Could it be suppressing the error?

  • http://www.pliggs.com Geoserv

    I have sent you a DM on Twitter, my php.ini file is set to show errors and keep an error log.

  • booger

    hey eamonn,

    Nothing yet… i¬¥ve done that modification before u update your script, but even db.php or removing the require_once and setup the database directly, after twitter redirect back to the confirm.php with the token the page stay there blank as before.
    i have a test version running at http://burl.me while i develop my theme :P

  • http://eamonnfaherty.co.uk eamonn

    @booger
    I checked out your site and i get the error Duplicate entry ‘tw_’ for key 2.

    Could you purge your twitter_user_map table and remove all twitter users from your pligg users table. Try the twitter login button and report back to me if anything was added to the tables.

  • http://eamonnfaherty.co.uk eamonn

    @Geoserv

    I didnt receive the dm. you can email me blog _at symbol_ designandsolve.co.uk

  • http://www.cronaca24.org identikit

    I can’t make it work.
    Booger can you share how you did it ?

  • renzo

    I have a black screen after twitter login. Any update of this?

  • lokrio

    Any help, I have a blank screen after twitter login too!!

  • http://eamonnfaherty.co.uk eamonn

    Hey all, sorry for the lack of help recently. I am getting married in 12 days and as you can imagine things are pretty hectic. If one of you wants to use the contact page to send me log in details to a dev site I don’t mind taking a look. Please make sure I can access your database too. Either command line or phpmyadmin I do not mind.

    all the best,

    Eamonn

  • http://eamonnfaherty.co.uk eamonn

    FAQPAL gave me access to his site. I have fixed the issue. The DB include is needed and is a Pear library. Give this a try and let me know how it goes.

    Eamonn

  • http://www.pliggs.com Geoserv

    Excellent work Eamonn, works perfectly.

    We ALL owe you one for this mod.

  • http://forums.pligg.com/questions-comments/19393-login-using-twitter-3.html#post86179 Login using Twitter | Page 3 | Pligg CMS Forum

    [...] a fully working version now. Sorry for the problems. It is my first mod. Grab version 4 from Log into Pligg using Twitter OAuth | Eamonn Faherty btw, you need to make sure you have Pear DB installed or you will have to rewrite the sql parts of [...]

  • lokrio

    Hi

    some people here who installed it are working very well….but I still don’t get it, i reinstall everything you said and, is blank screen.

    I’m not a web developer, could you be more specific on the change about the data base.

    Thanks…sorry my English

  • efern211

    Hello :)

    Thank you so so so much Eamonn for solving this for all of us. I have been through all sorts of trials and errors and I am so close to getting it to work. I followed all the directions, and right now I am not getting any error messages, but it’s not working like yours does. Twitter asks for permission and sends me back to my site with the twitter username and password correct. But, then my login says that the email and captchca are not correct. I fill those in and then I am logged in, but once I log out it gets all messes up and says the password is wrong. You can’t imagine the heartbreak! So close. All my users use twitter. So, this would be a huge deal for my site. Anyway, I’ll keep looking over the code. Thanks so much for your help so far!

  • efern211

    It goes once without an error message but if I refresh the browser I get this …. hmmmmm expired token? (I did the database patch too)

    Fatal error: Uncaught exception ‘EpiOAuthUnauthorizedException’ with message ‘ /oauth/access_token Invalid / expired Token ‘ in /home/efern211/public_html/twitter-login/EpiOAuth.php:249 Stack trace: #0 /home/efern211/public_html/twitter-login/EpiOAuth.php(228): EpiOAuthException::raise(‘__get(‘oauth_token’) #2 {main} thrown in /home/efern211/public_html/twitter-login/EpiOAuth.php on line 249

  • http://forums.pligg.com/modules-sale/20578-twitter-pack-sale.html#post91097 Twitter Pack for sale | Pligg CMS Forum

    [...] should be aware that a simple google search for "Pligg Twitter Login" would lead you to this. I would be interested at previewing your module to see how you were able to get around a few [...]

  • http://forums.pligg.com/modules-sale/20578-twitter-pack-sale-2.html#post91186 Twitter Pack for sale | Page 2 | Pligg CMS Forum

    [...] original poster. Anyone that can use google can see that this twitter login is already available here for free. No need to buy it and no need to chastise the original poster. Get the full Pligg [...]

  • http://forums.pligg.com/modules-sale/20578-twitter-pack-sale-2.html#post91212 Twitter Pack for sale | Page 2 | Pligg CMS Forum

    [...] original poster. Anyone that can use google can see that this twitter login is already available here for free. No need to buy it and no need to chastise the original poster. The majority of his [...]

  • 1984la.com

    I am getting a similar error as efern211.

    Is there anything we can do to fix the error?

    Thanks.

  • http://twitter.com/mktfan mkt fan

    Hey, I am pligg owner looking for this module. Could you provide me more info about this issue? I am desperate to achive this goal :( Many thanks in advance! Regards

  • Tyler

    Hey eamonn, I followed the link from Pligg.com to your blog. Are you still offering the twitter Pligg mod? I'm really interested in it, but I don't know where to get the zip file you are talking about