Tag Archives: OAuth

Facebook Javascript SDK – Logout with OAuth 2.0

Now we have OAuth 2.0 working with the Facebook Javascript SDK as mentioned in the last article.
Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

The above example is incomplete as there is no logout link. Replace the fb-login-oauth2.php as follow. Continue reading Facebook Javascript SDK – Logout with OAuth 2.0

Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

A few months ago, i published several posts about Facebook Javascript SDK but they no longer work since Facebook updates to OAuth 2.0. So this post is the updated version of
Facebook Javascript SDK – A Simple Login Page
and it should work works with OAuth2. Continue reading Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

Facebook Javascript SDK – Redirect to request for permissions page if the user is not logged in or not subscribed

We can find out the Request for permissions URL of a Facebook application as we discussed previously.
Facebook API – Request for permissions URL

So you can force the user to grant the permissions for your Facebook application by checking their login status and redirecting to the above URL if they are unknown user. Continue reading Facebook Javascript SDK – Redirect to request for permissions page if the user is not logged in or not subscribed

Facebook Javascript SDK – Logout

 
Update 2012-01-14: For OAuth 2.0 implementation, please refer to the new post.
Facebook Javascript SDK – Logout with OAuth 2.0

Update 2011-12-19: Since Facebook has updated their authentication system and HTTP to OAuth 2.0 and HTTPS. The following example will not work any more. i will update the post later. For more information, you can refer to Jerry Cain – Updated JavaScript SDK and OAuth 2.0 Roadmap

 

Add the following Javascript function for Facebook logout.

function logoutFacebook() {
  FB.init({ 
    appId:'<?php print YOUR_APP_ID; ?>', cookie:true, 
    status:true, xfbml:true
  });
  FB.logout(function() {
    // Reload the same page after logout
    window.location.reload();
    // Or uncomment the following line to redirect
    //window.location = "https://ykyuen.wordpress.com";
  });
}

Continue reading Facebook Javascript SDK – Logout

twitteroauth – Force User Login

twitteroauth is the first PHP Library to support OAuth for Twitter’s REST API. It is developed by Abraham Williams. You can download the source code @ GitHub and the example inside is quite easy to follow.
GitHub – abraham / twitteroauth
 

Unlike the Facebook API, the Twitter API does not support logout. If you want to increase the security, you can force user login every time when he/she clicks the Signin with Twitter button. This can be down by adding the force_login parameter in the GET oauth/authenticate request.
Twitter API – GET oauth/authenticate Continue reading twitteroauth – Force User Login

Facebook Javascript SDK – Reload/Redirect URL after Facebook Login

 
Update 2012-01-14: For OAuth 2.0 implementation, please refer to the new post.
Facebook Javascript SDK – Logout with OAuth 2.0

Update 2011-12-19: Since Facebook has updated their authentication system and HTTP to OAuth 2.0 and HTTPS. The following example will not work any more. i will update the post later. For more information, you can refer to Jerry Cain – Updated JavaScript SDK and OAuth 2.0 Roadmap

 

We tried a simple Facebook login using Facebook Javascript SDK yesterday.
Facebook Javascript SDK – A Simple Login Page

In the above post, the browser will not refresh the website URL after the Facebook login process is completed. We have to issue a refresh manually. Actually we can add the reload/redirect with just a simple API call.
Let’s add the FB.Event.subscribe in fb-login.php. Continue reading Facebook Javascript SDK – Reload/Redirect URL after Facebook Login

Facebook Javascript SDK – A Simple Login Page

 
Update 2012-01-13: For OAuth 2.0 implementation, please refer to the new post.
Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

Update 2011-12-19: Since Facebook has updated their authentication system and HTTP to OAuth 2.0 and HTTPS. The following example will not work any more. i will update the post later. For more information, you can refer to Jerry Cain – Updated JavaScript SDK and OAuth 2.0 Roadmap

 

Facebook API allows your website to interact with the Facebook content. A very common usage is to authenticate a Facebook user to your website. Let’s try it now.

1. Create the a Facebook App @ Facebook Developers.

2. Enter the website URL under Select how your app integrates with Facebook.

3. Upload the following file to your web server. This file should be located at the URL which we enter in step 2.
fb-login.php Continue reading Facebook Javascript SDK – A Simple Login Page