Login with facebook using coldfusion
Here is a example. How to make facebooklogin for a website using coldfusion?.
Before start you make a account with facebook.
Step 1 :
Create a app for your website using facebooklogin.here you can get app_key and secret_key.
Step 2:
Step 4:
You can see this screen :
Step 5:
After filling UserName and Password a screen show like this...
After click ok the redirect to logininformation:-
Output in logininformation.cfm
I hope this is useful for you. if you are facing any problem write us in comment. we are happy to solve that problem.
For more details visit these links : -
http://developers.facebook.com/docs/facebook-login/
//Permissions
http://developers.facebook.com/docs/reference/login/
https://developers.facebook.com/docs/reference/api/user/
Before start you make a account with facebook.
Step 1 :
Create a app for your website using facebooklogin.here you can get app_key and secret_key.
Step 2:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<!---You can fine app_key and secret_key by creating a account with facebook and make these by creating app for your website---> | |
<cfset api_key = "408300609288755"/> | |
<cfset secret_key = "86f3386be0df8c40dab97c8af3c0d237"/> | |
<cfset appID = "408300609288755"/> | |
<!--- Pass variable form here what you want to access form user account and redirect page for logininformation. | |
for more help visit http://developers.facebook.com/docs/reference/login/ | |
---> | |
<cflocation url="https://graph.facebook.com/oauth/authorize?client_id=#appID#&redirect_uri=http://www.thefutureminders.com/facebooklogin/loginInformation.cfm&scope=email,user_checkins,user_birthday" addtoken="no"> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!---Using Javascript ---> | |
<script> | |
function GoAuthancation() | |
{ | |
window.location = | |
"http://thefutureminders.com/facebooklogin/authentication.cfm"; //Url for authencate facebook login(path for authencation file) | |
} | |
</script> | |
<a href="javascript:GoAuthancation();"> | |
FaceBookL |
You can see this screen :
Step 5:
After filling UserName and Password a screen show like this...
After click ok the redirect to logininformation:-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<cfset api_key = "408300609288755"/> | |
<cfset secret_key = "86f3386be0df8c40dab97c8af3c0d237"/> | |
<cfset appID = "408300609288755"/> | |
<cfhttp url="https://graph.facebook.com/oauth/access_token" result="GetAccessToken"> | |
<cfhttpparam name="client_id" value="#appID#" encoded="no" type="url"> | |
<!--- Form here You can redirect your page on dashboard (After Login Page) ---> | |
<cfhttpparam name="redirect_uri" value="http://www.thefutureminders.com/facebooklogin/loginInformation.cfm" encoded="no" type="url"> | |
<cfhttpparam name="client_secret" value="#secret_key#" encoded="no" type="url"> | |
<cfif IsDefined('url.code')> | |
<cfhttpparam name="code" value="#url.code#" encoded="no" type="url"> | |
</cfif> | |
</cfhttp> | |
<cfif IsDefined('url.code')> | |
<cfhttp url="https://graph.facebook.com/me?#GetAccessToken.filecontent#" result="loginInformation"></cfhttp> | |
<cfset response = DeserializeJSON(loginInformation.filecontent) /> | |
<cfdump var = "#response#"> | |
<br /> | |
<br /> | |
<!--- This Information Is Used for insert in database ---> | |
<br /> | |
<br /> | |
<!---Member Login Information ---> | |
<table> | |
<tr> | |
<td>FaceBookUID</td> | |
<td>#response.id#</td> | |
</tr> | |
<tr> | |
<td>FaceBook ID</td> | |
<td>#response.link#</td> | |
</tr> | |
<tr> | |
<td>Name</td> | |
<td>#response.name#</td> | |
</tr> | |
<tr> | |
<td>Email</td> | |
<td> | |
#response.email# | |
<cfset Email="#response.email#"> | |
</td> | |
</tr> | |
<tr> | |
<td>First Name</td> | |
<td> | |
#response.first_name# | |
<cfset FirstName="#response.first_name#"> | |
</td> | |
</tr> | |
<tr> | |
<td>Last Name</td> | |
<td>#response.last_name# | |
<cfset LastName="#response.last_name#"> | |
</td> | |
</tr> | |
<tr> | |
<td>Gender</td> | |
<td>#response.gender# | |
<cfif response.gender EQ "male"> | |
<cfset Gender=1> | |
<cfelse> | |
<cfset Gender=0> | |
</cfif> | |
</td> | |
</tr> | |
<cfif IsDefined('response.birthday')> | |
<tr> | |
<td>Birthday</td> | |
<td>#response.birthday# | |
<cfset BirthDate="#Day(response.birthday)#"> | |
<cfset BirthMonth="#left(MonthAsString(Month(response.birthday)),3)#"> | |
<cfset BirthYear="#Year(response.birthday)#"> | |
<cfelse> | |
<cfset BirthDate=""> | |
<cfset BirthMonth=""> | |
<cfset BirthYear=""> | |
</td> | |
</tr> | |
</cfif> | |
<cfif IsDefined('response.hometown.name')> | |
<tr> | |
<td>HomeTown</td> | |
<td>#response.hometown.name# | |
<cfset BirthCityNumber="#response.hometown.name#"> | |
<cfelse> | |
<cfset BirthCityNumber=""> | |
</td> | |
</tr> | |
</cfif> | |
<cfif IsDefined('response.relationship_status')> | |
<tr> | |
<td>Marital Status</td> | |
<td>#response.relationship_status#</td> | |
</tr> | |
</cfif> | |
<cfif IsDefined('response.location.name')> | |
<tr> | |
<td>Location</td> | |
<td>#response.location.name# | |
<cfset LivingCityNumber="#response.location.name#"> | |
<cfelse> | |
<cfset LivingCityNumber=""> | |
</td> | |
</tr> | |
</cfif> | |
<cfif IsDefined('response.bio')> | |
<tr> | |
<td>AboutMe</td> | |
<td>#response.bio#</td> | |
</tr> | |
</cfif> | |
</table> | |
</cfif> | |
</cfoutput> |
Output in logininformation.cfm
I hope this is useful for you. if you are facing any problem write us in comment. we are happy to solve that problem.
For more details visit these links : -
http://developers.facebook.com/docs/facebook-login/
//Permissions
http://developers.facebook.com/docs/reference/login/
https://developers.facebook.com/docs/reference/api/user/
Comments
Post a Comment