9lessons programming blog
Loading Search
9lessons Bring Friends
Wall Script
Follow Me:
Thursday, February 17, 2011

Login with Facebook and Twitter

Facebook and Twitter have become large in the social network world and both networks offering oAuth support. We developed a system to login with Twitter and Facebook. Nowadays web users not interested to filling the big registration forms. This script helps you to avoid registration forms, It’s is very useful and simple to integrate.

Facebook Twitter Login


Download Script     New Live Demo

Developer
Ravi Tamada
Ravi Tamada
Designer Developer & Freelance
Chennai, INDIA
androidhive.info

Database
Sample database users table columns id, email, oauth_uid, oauth_provider and username.
CREATE TABLE users
(
id INT PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(70),
oauth_uid VARCHAR(200),
oauth_provider VARCHAR(200),
username VARCHAR(100),
twitter_oauth_token VARCHAR(200),
twitter_oauth_token_secret VARCHAR(200)
);

The tutorial contains three folders called facebook,twitter and config with PHP files.
facebook //Facebook OAUTH library
twitter //Twitter OAUTH library
config
-- functions.php 
-- dbconfig.php //Database connection
-- fbconfig.php //Facebook API connection
-- twconfig.php //Twitter API connection
index.php
home.php
login-twitter.php
login-facebook.php
getTwitterData.php

Facebook Setup
You have to create a application. Facebook will provide you app id and app secret id, just modify following code
fgconfig.php
<?php
define('APP_ID', 'Facebook APP ID');
define('APP_SECRET', 'Facebook Secret ID');
?>

Twitter Setup
Create a twitter application click here. Some like Facebook Twitter provide you consumer key amd consumer secret key using these modify following code.
twconfig.php
<?php
define('YOUR_CONSUMER_KEY', 'Twitter Key');
define('YOUR_CONSUMER_SECRET', 'Twitter Secret Key');
?>

dbconfig.php
Database configuration file.
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

login-twitter.php
In root directory find out the below line at login-twitter.php code and replace yourwebsite.
$request_token = $twitteroauth->getRequestToken('http://yourwebsite.com/getTwitterData.php');

index.php
If you want to modify your web project existing login or index pages, just use following code.
<?php
session_start();
if (isset($_SESSION['id'])) {
// Redirection to login page twitter or facebook
header("location: home.php");
}
if (array_key_exists("login", $_GET))
{
$oauth_provider = $_GET['oauth_provider'];
if ($oauth_provider == 'twitter')
{
header("Location: login-twitter.php");
}
else if ($oauth_provider == 'facebook')
 {
header("Location: login-facebook.php");
}
}
?>
//HTML Code
<a href="?login&oauth_provider=twitter">Twitter_Login</a>
<a href="?login&oauth_provider=facebook">Facebook_Login</a>

If any queries please comment here.

Thanks,
Srinivas Tamada
Comments
{ 496 comments }
Anonymous said...

awesome!

Dias, Victor said...

Nice man ..

Anonymous said...

Wow... nice and easy

Norant said...

amazing!!!

Anonymous said...

GOOD :D

Beben said...

perfect....\m/

Gentoo Maniax Groups said...

Cool,........keep inspiring, Bro....!! Thanks

wadday said...

Superb ravi... its really cool.. keep it up..

Anonymous said...

this is great simple, can you add google ?

jeannot said...

Nice tut! i was lookin for one alike a long time now. but i'm confronting some problems installing it if anyone can help me: when i go on the page index.php and click on facebook login i got an erro type:Parse error: syntax error, unexpected '{' in /homez.167/wacomori/www/Login_Twitbook/login-facebook.php on line 17

Thx a lot

Srinivas Tamada said...

We have been working with Google Oauth. Second version Google + Yahoo + Facebook + Twitter

goc said...

i'm having problems ... when logging in i'm redirected back but only query result from oauth provider is shown as an array ... can you take a look ?

Anonymous said...

"We have been working with Google Oauth. Second version Google + Yahoo + Facebook + Twitter"

That will be great as well, thanks!

Website Designers said...

I impressive very much you are right thing in this post any face book or twitter attachment in the Google. Thanks sharing this important information.

Anonymous said...

epic nice.. awosome :D

openfancy said...

nice work!

but facebook login seems to be tricky..
can´t get it working, there´s always the "There was an error." message...

hope someone can help!

Srinivas Tamada said...

Subscriber emails updates

Anonymous said...

nice work.............

still need better

iv0id said...

Really awesome , thanks you

Irwan said...

wow...great .thanks bro

jeannot said...

hi ! it seems that my php version 4 doznt support the use of try and catch and gimme somme error on page login-facebook.php. can someone give some information on it !!!

sarfaraz said...

Gud Greetings

When ever I am trying to use oath account whether it is of yahoo, gmail or facebook
below error came out.
Can any one help me.

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\facebooklog\facebook\facebook.php on line 4
( ! ) Exception: Facebook needs the CURL PHP extension. in C:\wamp\www\facebooklog\facebook\facebook.php on line 4

Thiago said...

Facebook Login Error:
------------
Invalid Argument

Given URL is not allowed by the Application configuration.
------------
?!?!?!?!?!?

Juan Ardila Serrano said...
This comment has been removed by the author.
Anonymous said...

tink's brained :)

Anonymous said...

Hey I'm going crazy here, Im getting this error every time after I click "Allow" -> Warning: Cannot modify header information - headers already sent by (output started at /.../getTwitterData.php:18) in /.../getTwitterData.php on line 35. Help!

jeannot said...

Dats great i've put the alternative connexion with twitter on my website here is the adress:http://wacomori.com . Thanks a lot Srinivas for this tutos.

Anonymous said...

Anonymous said...
Hey I'm going crazy here, Im getting this error every time after I click "Allow" -> Warning: Cannot modify header information - headers already sent by (output started at /.../getTwitterData.php:18) in /.../getTwitterData.php on line 35. Help!

-> delete all empty lines in files BEFORE SENDING ANYTHING TO WEB SERVER !!!

Inwebdeveloper said...

thanks for sharing the code

rob said...

Sweet dude. I've been looking everywhere for something simple and clean like this.

Tom said...

i was using the FB button code to make my call to facebook - not this style - how can i call the session/login with the same parameters as my generated button?

Anonymous said...

Excellent post, I would like to download the updated version of the demo, where after login follow the record of the email.

Thanks!

Anonymous said...

Can you provide code for login through Linkedin

Anonymous said...

The script worls perfectly.

To store oauth_uid of the user, oauth_uid int(11) no longer works...that should be changed to higher varchar ...

weFix said...

please help me...... covert this codes to ASPx...


Regards
Sanoj

Anonymous said...

Great Job! Srinivas Tamada I´m really interesting in version 2. Google + Yahoo + Facebook + Twitter... login. When do you think it will available? Thanks in advance

Anonymous said...

Great! I am waiting for new version(Google + Yahoo + Facebook + Twitter).

thanks for the code.

Odeio A TV Meio Norte said...

Facebook page: facebook.php linha 108 add:
---------------------------------|
CURLOPT_SSL_VERIFYPEER => false, |
CURLOPT_SSL_VERIFYHOST => 2, |
---------------------------------|

public static $CURL_OPTS = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
);

Odeio A TV Meio Norte said...

line:108 facebook.php ADD:
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,

------------------------------------------

public static $CURL_OPTS = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
);

Srinivas Tamada said...

Emails updated

Anonymous said...

Logout not working: Session cookie still alive

Srinivas Tamada said...

Here just storing Oauth tokens.

casildonet said...

I just installed it, and man! Works like a baby's ass -smoth-

Anonymous said...

thanks

giorgi said...

sarfaraz

you need to enable curl
if u run windows do it
by uncommenting the extension=php_curl.dllin the xampp\apache\bin\php.ini file

if debian
apt-get install curl php5-curl libcurl3-dev

*php5 - installed php version

Dashzeveg said...

Help me:

What is CURL?

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\xampp\htdocs\new\facebook\facebook.php:4 Stack trace: #0 C:\xampp\htdocs\new\login-facebook.php(3): require() #1 {main} thrown in C:\xampp\htdocs\new\facebook\facebook.php on line 4

Dashzeveg said...

amazing

Talk2toks said...

This tutorial is really amazing and i have been thinking on how to play around all the social Network account and merge them together facebook, twitter and linkedin. But you issue am having is am having difficulties in downloading the tutorial. Kindly help cos i have registered..

Anonymous said...

Amazing i got the script without suscription !!!! This is the most security mode i ever seen on the web. Congrats my friend

Talk2toks said...

Thanks i just got the script after trying for so long but it took more than 18hrs.. Anyway, thanks and keep blogging.....

sam said...

hi,nice tutorial...
I have a problem
...when logging in i'm redirected back but only query result from oauth provider is shown as an array
What should i do??

Hermes Flores said...

buenos dias! Gracias por este valioso tutorial!, les cuento que en el archivo login-facebook.php la redireccion a la pagina de inicio no se deberia hacer con header("Location: index.php"); sino mediante javascript, esto para evitar un email de de facebook solicitando que en la pagina final de retorno(en este caso el index.php) no exista contenido de terceros como < script>< img >< iframe >.

Saludos

Thiago said...

facebook login error -> There was an error.

What should I do?

Anonymous said...

so how can i have database for it ?

Anonymous said...

why logout is not working???? session is still alive :(

that driving me crazy... help help... help

Thanks,
Mit

Srinivas Tamada said...

This system will not clear facebook and twitter sessions.

Anonymous said...

where is 'Facebook Secret' i dont see it. I see the other three but not 'Facebook Secret' code?

Anonymous said...

theres no store-email.php file like your demo has. after you get permission from fb or twitter, no email page included.

suramya said...

Good one..Thanks a lot

Anonymous said...

it's not working on my pc, I've put AppId and Secret id and created table and created connection, all things are fine but not working, don't know why... please help me

Anonymous said...

HI Srinivas,
thank you for this tutorials,
i'm working with symfony framework, have you an idea how implement this in symfony project ?

Anonymous said...

Getting Message

There was an error.


help me

semakula said...

Getting Message
There was an error
Please help me

Anonymous said...

Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' bro i got this problem any idea?

Anonymous said...

how we get user id after login in twitter

rohit said...

i am getting this error i try to install it on wamp server
Fatal error: Call to undefined function curl_init() in C:\wamp\www\Login_Twitbook\twitter\twitteroauth.php on line 199
please help me out

MOHAMMED ASHFAQ said...

WAAAAAAAAAAAAW.....

Anonymous said...

i am also getting this error i try to install it on wamp server
Fatal error: Call to undefined function curl_init() in E:\wamp\www\Login_Twitbook\twitter\twitteroauth.php on line 199
please help me out

CyberKatze said...

THANKSSSSSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! great topic!

Caio said...

Pleas could you help me?

Facebook Issue:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /login-facebook.php:29) in login-facebook.php on line 36

Warning: Cannot modify header information - headers already sent by (output started at login-facebook.php:29) in login-facebook.php on line 42

Twitter issue:
Warning: Cannot modify header information - headers already sent by (output started at fb-twitter/getTwitterData.php:18) in fb-twitter/getTwitterData.php on line 35

Thanks!

Anonymous said...

Hi Srinivas Tamada,

What is the Callback URL? i put in twitter? thanks..

Anonymous said...

Getting Message

There was an error.


help me

OsMeNDa said...

thanks

Anonymous said...

Hello i need help please im begging for help.

i get the display of user info from twitter

but at the bottom of the result page i get

Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/******/getTwitterData.php:16) in /home/******/public_html/******/getTwitterData.php on line 33

ZREN said...

i have too same error how can we fix it

Anonymous said...

To solve headers error - erase all blank lines and spaces after the close php tag which looks like this " ?> "

Anonymous said...

Add ob_start(); at the top of the page giving you the error headers already sent by (output started at this and that....

Example:

<?php

ob_start();


Any page that session_start(); is used, make sure that session_start(); is the first variable at the top of your code b4 any other code begins.

Example:

<?php
session_start();

Anonymous said...

Please help, How do i get the user email address from both facebook and twitter after authentication has been performed and the user details saved to my database. It's just the user fullname that is saved to my database and no email address. I need to get the user email address as well. please help.

Thanks in advance.

breteuil said...

thanks for this great tuto which works well

i'm now facing an issue while integrating this to my existing login system: no problem for new users but how do you deal with existing(old users)?
i think i'll need to sync their old account with their facebook and twitter login based on their email address

the only way to do that is to ask this to the user, do u have any other solution in mind?

Anonymous said...

Could you pls tell me how to get the user email address from Facebook and Twitter?


Breteuil all you need to do is to modify the file config/functions.php insert the user details brought from Facebook or Twitter so that those information can be inserted into your current users table and see how you can create a session variable in the page (login-facebook.php) for users who logged in with their facebook accounts and (getTwitterData.php) for users who logged in with their Twitter accounts and change the header("location: home.php"); in those two files to take the user to the page that your users see upon a successful login.

Hope that solves your problem.

My own problem is how to get the users email from Facebook and Twitter...

Dalamanli said...

Hi, thanks for this tutorial.

i started to subscribe 3 days ago.

but still i cant get download link

Suramya said...

good one :) thanks a lot working fine

Suramya said...

twitter login working fine and in the facebook login an error occurs when testing in local. The problem solved by adding one additional line in facebook.php in the makeRequest() method there $opts = self::$CURL_OPTS;
Immediately following it, add:
$opts[CURLOPT_SSL_VERIFYPEER] = false;

:) its working fine now

Chris K said...

great code, very useful.

any idea on what the connect_url in FB should be?

Srinivas Tamada said...

Mail updated 27 July 2011

Anonymous said...

What URL do I set up on FB?

To fix this error, please set your Connect URL in the application settings editor. Once it has been set, users will be redirect to that URL instead of this page after logging in.

Anoop Parihar said...

i am getting error.. following message is coming "There was an error" .. what is problem?
please guide me. thanks

akki said...

hi i am getting a problem in login with yahoo..
i am using code--
$session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
if (is_object($session)) {
$user = $session->getSessionedUser();
$profile = $user->getProfile();
$name = $profile->nickname; // Getting user name
$guid = $profile->guid; // Getting Yahoo ID
}
but when i click on yahoo login button page remain same. i also define OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID.
but if i do:--
if (!is_object($session)) {echo "djf"; }
its working ..plz help me

Anonymous said...

please how to make a update of status on twitter ?.. i try used http://www.9lessons.info/2010/02/connect-twitter-api-with-oauth-using.html but don't work, help me please Srinivas :]

Anonymous said...

http://socialtweet.us/ Mobile Twitter Client with fast access, very minimalist design and rich of features that you don't get on the normal mobile Twitter site.
Designed with a very slim method so it will speed up the access and of course save the cost.

Michael De Guzman said...

i have this message...


There was an error.


how do i resolve this? any ideas

Michael De Guzman said...

Getting Message

There was an error.


help me

Facebook login said...

Nice Post for Facebook and Twitter login's thanks lot...

Anonymous said...

There was an error.

ClintWK said...

Is it possible to make it so that if the user isn't already logged in via twitter or facebook, then instead of loading the same page with the login request, it instead loads in a pop-up or drop-in or a jQuery reveal?
gomtv dot net has a version that does a pop-up and a demo(not of the fb/twitter login though) of the reveal or drop-in can be found at zurb dot com/playground
Great work btw, I love this site and signed up for twitter just to test this and follow you! :D

ClintWK said...

Oh, just thought of one mroe thing!
Could you also add a remember me check box option so that if the same user comes back to the site and previously checked that field it will attempt to auto log them into facebook or twitter if they're already logged into one of those two places?
Thanks!

AAMIR VAHID BLOG said...

how to get user email and gender along with username to insert in mysql

Argonic Metal said...

wow ... amazing tutorial :D I really love it ... and I hope if the redirection will in a popup window and returning the results in div in the main window ...

brent said...

I have signed and and it want let me download

toem said...

I dont what is wrong, from all the comment in this post, most of reader doing fine with this tutorial, but i got a problem when login to FB, it say my application is is under construction.

toem said...

i fixed that problem i post before, but now i had anothr problem, when i click the fb login button and allow app access, it redirect me to this url: login-facebook.php?session={"session_key":"2.AQCAvTZGKTY-sAz9.3600.13150bla bla bla bla.

and i got message on browser: There was an error.

i really dont what to do, because after this happen when i click fb login button, the allow form never apear. just "There was an error" that show in browser, plizz help me with this..

toem said...

hi sir... Problems solved, my site already connected, just one thing, how to get user email from fb (not manualy input) and put it in mysql DB? in the email column just apear "NULL"

Srinivas Tamada said...

@toem

This system not storing facebook email manual update. Storing twitter and facebook tokens

Srinivas Tamada said...

We going to update this post soon with storing fb email.

toem said...

Ty sir... i'll bookmark this post, for your next update.. :)

Anonymous said...

Update to SDK 3.1.1 and you can use

$facebook->getLoginUrl(array('scope'=>'email'));

to get the user's email

Anonymous said...

awesome.. is there a way to store twitter username instead of full name? or maybe both? thanks

Anonymous said...

I can't wait for the update :)

manos said...

hello i have problem the facebook url back after login not working why??
Thanks good job!!

Hemendra Kumar Saini said...

Great, this will great option in forums or question and answers website.

JacK said...

hello

if i want to try in localhost.
what should be changed?

and i cant download the script

yogesh saroya said...

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\Facebook_Twitter_Login\facebook\base_facebook.php:19 Stack trace: #0 C:\wamp\www\Facebook_Twitter_Login\facebook\facebook.php(18): require_once() #1 C:\wamp\www\Facebook_Twitter_Login\login-facebook.php(3): require('C:\wamp\www\Fac...') #2 {main} thrown in C:\wamp\www\Facebook_Twitter_Login\facebook\base_facebook.php on line 19

Hasan said...

The following message is:

... Something wrong happened ... when clik log to twitter

Please tell me where's the error....

Hasan said...

When click twit button, messsage is

the error code is: 401
Something wrong happened.

Srinivas Tamada said...

$Hasan

Please give valid twitter CONSUMER_KEYs

Roger said...

The page isn't redirecting properly.

This is the problem I am facing when I am trying to log with facebook details . It worked once for me. But after that it doesn't work. Also it would be really helpful if you could please make the log-out.

PRAG KALRA said...

Hello Srinivas Sir

i have error.

You don't have permission to access /getdata.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

for more Go on www.prag.asksanju.com

Login said...

First off all thanks,
Hi Srinivas i got following error facebook login

Warning: Missing argument 5 for User::checkUser() in fblogin/login-facebook.php on line 35 and config/functions.php on line 7

How resolve resolve it?

Srinivas Tamada said...

Check the SQL statments

Login said...

Hi Srinivas,

I didnt change anything i just followed ur steps but this error coming

Warning: Missing argument 5 for User::checkUser() in fblogin/login-facebook.php on line 35 and config/functions.php on line 7

Where should i check? Can you please let me know

Srinivas Tamada said...

I will recheck the download script.

Gokul said...

Hi I got the following error in facebook login page. What i do. Help me. Thanks.

Invalid Argument

Given URL is not allowed by the Application configuration.

Anonymous said...

nice job! thanks!

Login said...

Hi srinivas

I didnt change anything i just followed ur steps but this error coming

Warning: Missing argument 5 for User::checkUser() in fblogin/login-facebook.php on line 35 and config/functions.php on line 7

Where should i check? Can you please let me know

alejandro soberanes said...

Hi, can you help me with this? can I tweet from that documents?

James said...

Hi is this possible to port this over to wordpress?

Srinivas Tamada said...

Download script working perfect. I had re-tested

http://demos.9lessons.info/fttest/index.php

Login said...

Hi srinivas

Again donwloading and check it same error after giving facebook login

Warning: Missing argument 5 for User::checkUser() in fblogin/login-facebook.php on line 35 and config/functions.php on line 7

Can you please let me know

Matze said...

Hallo!
In Database oauth_uid int(11) Field is to short.
I changed it in varchar(255) and it works.

The warning is because of
$userdata = $user->checkUser($uid, 'facebook', $username,$email); -> 4 Arguments
and function checkUser($uid, $oauth_provider, $username,$email,$twitter_otoken,$twitter_otoken_secret) -> 6 Arguments

Greetings

Login said...

Hi Srinivas ,
Can you help me following error

Chkuser?

Warning: Missing argument 5 for User::checkUser() in fblogin/login-facebook.php on line 35 and config/functions.php on line 7

Where should i check? Can you please let me know

Srinivas Tamada said...

@Matze Thank you. Download script and table updated.

Login said...

Hi srinivas,
Iam getting error both Facebook and Twitter login same error is

Column count doesn't match value count at row 1

can you help me how to resolve this issue

Srinivas Tamada said...

Updated insert statement

komputer said...

Hy Srinivas

i was test your app login fb n twit but i dont understand why alaways display

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Dax87 said...
This comment has been removed by the author.
Nate said...

Srinivas, I got your code uploaded on one of my developer sites and the Twitter required some work, I had to put ob_start(); on the getTwitterData.php page and move session_start(); above it at the very top of the page. It works fine now, very smooth. I also changed the username to screen_name so it uses people's @ name instead of their name which may have spaces or symbols.

Anyway, I can't get your Facebook code to work. As komputer said above, it just sits in an endless redirect loop. I didn't modify any code, I just added my keys. It's been a day so I'm sure Facebook's stuff is propagated through their servers. I don't know where to start looking, I just know that nothing is added to the database.

Any help would be appreciated, thanks.

Anonymous said...

Awesome tutorial. Thanks for sharing. One question. i keep getting #_=_ at the end of all urls after login. Any idea on how to not have this happen?

Anonymous said...

If you use this you may want to include some mysql_real_escape_string(). I have an apostrophe in my name and the script had an error. if you add the real escape function to fields being inserted into database it makes it safer and also prevents errors when someone like me tries to sign up. Damn irish and their apostrophes hehe!

Anonymous said...

thanks this is help for my knowledge

Manish Nagar said...

it very nice and excellence, i want script for login with facebook and twitter, i subscribed it..please send me script thanks dear

manly said...

When a facebook profile name has ' or " i get an sql error!

kamal said...

where is the java script code ????

Nnamdi Ekesiobi said...

For over a month now I trying to open twitter but I can

Anonymous said...

wait google+yahoo+facebook+twitter

Manish Nagar said...

hi sriniwas its great application i need script for linkedin and facebook + twitter+yahoo+gmail please help thanks

Yogesh Saroya said...

sir help
error in twitter
Fatal error: Call to undefined function curl_init() in /www/99k.org/l/o/v/lovesongs/htdocs/fb/twitter/twitteroauth.php on line 199


in facebook:

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in /www/99k.org/l/o/v/lovesongs/htdocs/fb/facebook/base_facebook.php:19 Stack trace: #0 /www/99k.org/l/o/v/lovesongs/htdocs/fb/facebook/facebook.php(18): require_once() #1 /www/99k.org/l/o/v/lovesongs/htdocs/fb/login-facebook.php(3): require('/www/99k.org/l/...') #2 {main} thrown in /www/99k.org/l/o/v/lovesongs/htdocs/fb/facebook/base_facebook.php on line 19

Anonymous said...

i am using facebook login logout api. if i login from my site it will login successfully but if i do logout it will logout from my site but cant broke the session from facebook. it will directly login into facbook not even ask for username and password.

ayhoung said...

is there any way to separate first name and last name via facebook API?

Matteo Pagliazzi said...

the oauth uid is unique to the current logged user?

God's Computer said...

useful

her.arya said...

please help me error "Column count doesn't match value count at row 1"

Brij Kishor Rajput said...

i was test your app login fb n twit but i dont understand why alaways display

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Anonymous said...

replace the file config/functions.php

oauth_provider, oauth_uid, username,email,twitter_oauth_token,twitter_oauth_token_secret) VALUES ('$oauth_provider', '$uid', '$username','$email','$twitter_otoken','$twitter_otoken_secret')

Venky said...

As KOMPUTER and NATE mentioned above:
I am facing the same issue with facebook login. The page redirects to facebook back to localhost and to facebook again... And it gets looped... the browser gives up :(. Please help.

Thanks,
Venkat

WARDI said...

Hello, Thnx alot for this,
I am trying to customize this work and make it worke with Symfony 1.4 framework, already started working on it, if anyone can offer help contact me please, :)

Amorz said...

Thanx awesome script and works fine for me!!

mayid said...

What about logging in via ajax? I'm on a project that doesn't have page reloads. And by other side, i know a fb connect script that opens a new window to authenticate and then sends login info as a callback. This can be achieved with this script?

mayid said...

I tried accessing the code vía ajax, and also using iframes. The first thing wont help at all, because no secondary window can be reached that way. I can return the $url instead of redirecting, but what then? And the second try, the iframes, won't work. They remain blank for twitter and Facebook just post a link instead of a login formulary.

zawmyohtet said...

Thanks for your tutorial.But I can't download script.

Anonymous said...

Thanks. I can't download the script, though.

Gooner Grays said...

Same problem as her.aya. Asks me for the Facebook permissions but then when redirecting back get the following error

please help me error "Column count doesn't match value count at row 1"

Would be great if you could post a response to this. Otherwise smooth as a Cashmere codpiece.

Anonymous said...

Thanks for the Script! its awesome .. my FB-SIgn in works well!
but my twitter errors all the time "Something wrong happened."

twconfig.php is fine! both keys are fine ..
Help me please ..

Karapalis said...

That is all i want, thanks

Anonymous said...

Now I know why you have no negative comments. You screen them! What a joke.

Anonymous said...

am getting "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." i just added my app key and secret.

Anonymous said...

Hi Very nice tutorial.

But i got an error to connect with facebook

error message are as follow:

"An error occurred with test. Please try again later."

Jorge said...

Hi Gooner, I had the same problem. It is because of a wrong INSERT statement in functions.php file. Go to that file inside the config folder and at the end of line 15 where you see:

...'$email')") or die(mysql_error());

add the two missing columns like this:

...'$email','$twitter_otoken','$twitter_otoken_secret')") or die(mysql_error());

That worked for me.

BTW, great script Srinivas! Thank you very much.

dvidsilva said...

my hosting provider doesnt allow me to curl_exec


Warning: curl_exec() has been disabled for security reasons in /home/memegust/public_html/m/login/facebook/base_facebook.php on line 803


is there an alternative?

Srinivas Tamada said...

@dvidsilva

Please sent a request to hosting people to enable CURL_EXEC()

atul said...

please send

Frankie said...

Hi
I think I am missing an idea here.
Say you have a simple database of members that contains, name, email login and password, and city. WHen they log in you can say "Hello " for example. That's all normal standard stuff.

If someone logs in using Twitter or Facebook, how do you know their name? Their email? Their City?

This is really basic but important stuff. So far I have found no one who can answer this fundamental question.

Anonymous said...

i like it,WOW

brij-shivam said...

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\xampp\htdocs\Facebook_Twitter_Login\facebook\base_facebook.php:19 Stack trace: #0 C:\xampp\htdocs\Facebook_Twitter_Login\facebook\facebook.php(18): require_once() #1 C:\xampp\htdocs\Facebook_Twitter_Login\login-facebook.php(3): require('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\Facebook_Twitter_Login\facebook\base_facebook.php on line 19

brij-shivam said...

nice...

David said...

Does the Twitter app require a callback URL or should I leave that blank?

Dazzlera145 said...

thanks, super example and I'm slowly picking my way through it.... I installed it on a test machine with internet connection but where Apache was running on localhost and a localhost entry in my host table for my website.... anyway after a cpl of hours (and a fee beers).. the code seemed to get stuck in an endless redirect loop (like some of the above people have said).. thuinking about it it does look like facebook makes a call back to the php script.. which it can't do if your running your site on a test locahost set up like me... I moved the code on to the live server and it worked straight away!... thought this might be off use to someone

snack box said...

Its good or not? but This system not storing facebook email manual update. Storing twitter and facebook tokens.. its ok for me. @puffpie_snack

SEO Website Design said...

I like facebook and twitter api connect. But after reading this.. need to think how it work, in more good manner. Thanks

andres said...

Excelent!!! man, i find an issue in the CURL certificate problem, i fixed it writing these two lines in the Facebook.php File after the line 112.

CURLOPT_SSL_VERIFYPEER => false, //this fix the Certificate CURL problem
CURLOPT_SSL_VERIFYHOST => 2, //this fix the Certificate CURL problem

I hope this helps. Greetings.

kevin kavs said...

coool, worked pretty well too.

kundan said...

Good......!

Anonymous said...

Hi..

Can someone help me out with this.Need this urgently.I ve followed the exact tutorial.I keep getting this error-"There was an error".
Need someone to help me out with the configuration on Facebook Apps.
Waiting for a response
Thanks.

wolf__#01' said...
This comment has been removed by the author.
Ho Duc Hung said...

Imagzing

Ho Duc Hung said...

Amazing

keoladeo national park said...

hello sir i need this script i am already signup my email with this site but i can't download file. please help me.

Anonymous said...

Hi,

what this error means -

Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in D:\xampp\htdocs\Facebook_Twitter_Login\facebook\base_facebook.php:19 Stack trace: #0 D:\xampp\htdocs\Facebook_Twitter_Login\facebook\facebook.php(18): require_once() #1 D:\xampp\htdocs\Facebook_Twitter_Login\login-facebook.php(3): require('D:\xampp\htdocs...') #2 {main} thrown in D:\xampp\htdocs\Facebook_Twitter_Login\facebook\base_facebook.php on line 19

Anonymous said...

Hi,

why its comes?"An error occurred with APP-NAME. Please try again later." How to resolve?

Anonymous said...

Hello. I downloaded this script but when I want to join with facebook there is error "Column count doesn't match value count at row 1" I think that problem is in functions.php with insert into... i dont knot but when I put the information to the databaze manually the script is working perfect. Thank you for your responze.

Unknown said...

This script is great. Works like a charm. Thanks!

Žiga said...

Just great script. Thanks for sharing it. Hope to find something else usable.

Anonymous said...

Like It!!!

Anonymous said...

Hi

I am unable to connect when i click on Facebook login button just got following error:
There was an error.

Actually i want to integrate setting with my forum by using existing login option..here is my forum:
http://www.jbpguide.com/forums

Please tell me is that possible to integrate that script with my forum by doing something different? Although in my forums Admin panel there is option to connect with facebook and twitter but these are also not working.. :(

Anonymous said...

How can i use?:
$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> 'Testing posting to my wall', 'cb' => ''));

Want to post on a fb wall if they are sending a message.

Faisal Iqbal said...

how I get facebook and twitter library?

Anonymous said...

its better

Anonymous said...

thanks

Anonymous said...

Can you please tell me how to intergrate the fb wallpost function correctly if the user is logged in with facebook?

$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> 'Testing posting to my wall', 'cb' => ''));

Umar Farooq said...

i am getting this error
An error occurred with APP Name. Please try again later.

Umar Farooq said...

can any one help me ?

i am getting this error

An error occurred with APP Name. Please try again later.

Post a Comment