facebook redirect after app authentication - facebook

I am developing a functionality to allow facebook users to register in our web application.
The approach is:
We will create one app on facebook
Facebook authentication plugin (http://developers.facebook.com/docs/guides/web/#login) will be used in our registration page.
When user clicks on facebook button, facebook login page and then app authorization page are shown.
One user allows/disallows facebook app, user will be redirected to a particular page within our website.
I am not able to find a proper even handler to capture app authorization (allow/disallow event) to redirect user. Can someone help me with this?

Using the JS SDK:
FB.login(function(response) {
if (response.status=="connected") {
// authorized the app
} else {
// did not authorized the app
}
}, {
perms: 'email'
});
Trigger a call to this function when the user click the button.
<div class="fb-login-button">Login</div>

Related

after login redirect does not work facebook cakephp

I am integrating webtechnick facebook plugin , my cake version is 2.3.1. When I click Facebook login button, the fb window appears, and when I type my fb email and password it disappears, but does not refresh the page, I have specified the redirect page like
public function afterFacebookLogin() {
$this->redirect ( '/posts' );
}
The interesting thing, that when after this, I one time manually refresh the page, it already redirects to /posts page and also I can see that the user is logged in.
THanks

How do you create a mobile friendly Like Gate for a Page on Facebook?

I've put a Like Gate on a few of my Facebook Pages and I'm getting a lot of complaints saying that people can't access the content via their mobile device since the mobile version of the facebook website, and the facebook apps for ios/android, don't support tabs on Facebook.
I see there are services out there (I'm not sure how legit they are) that offer a way to create a mobile like gate for your page tab, but I can't find any documentation on how they do it. These services are not suitable for me, because the content on my tab is custom and dynamic.
So, how can I create a interstitial page for a mobile page that requires the visitor to have liked my Page on Facebook before they can proceed? This has to work for new users, as well as existing users who re-visit the tab and without requiring an install to an application.
Thanks!
One approach you can take for a mobile site is to check that the user has liked the page in question via the JS SDK.
If you have a logged-in user to your application, you can Subscribe to the authResponseChange FB event within your JS SDK initialization, or call a function directly to make an API request to verify if the user is a fan of your page.
In your initialization:
FB.init({appId: YOUR_FB_APP_ID_HERE });
window.fbAsyncInit = function() {
// React to a user clicking an on-page Like button:
FB.Event.subscribe("edge.create", verifyUserLikesPage);
}
You can verify that the user likes the appropriate page in the like handler:
function verifyUserLikesPage() {
FB.api("/me/likes/"+FBID_OF_PAGE_TO_ENSURE_THEY_LIKE, function(apiResponse){
if (apiResponse.data && apiResponse.data.length > 0)
// User likes the page. Enabled them to proceed
else
// User does not like the page. Require they click Like.
}
}
More information on the edge.create subscribe via JS available here: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Logging in through Facebook, if not registered, should redirect to registration page

My site has the option of registering with and without facebook. When you register with facebook though, extra information is needed. This is fine, as I use fb:registration and specify extra fields.
However, the problem is, when a user comes to the site and hasn't registered, sees the facebook login button and clicks it, the link brings them to facebook to login and the app is registered and bypasses the registration form I have.
I there a way to redirect a non-registered user that is not logged in with facebook to a registration page instead of adding the app?
You can add the registration-url parameter to the login button as documented in the Login + Registration Flows section.
<fb:login-button
registration-url="yoururl" />
This isn't documented so I don't know if it will continue to work but if your using the HTML5 version of the login button then you can use:
<div class="fb-login-button" data-registration-url="yoururl">Login with Facebook</div>
Not 100% sure i understood you but..
Going on the assumption that you only want users who have an active FB browser session and have authorized the use of your application with their account to see your login button/a particular page you could try this right after your FB.init:
FB.getLoginStatus(function(response) {
if(notLoggedIntoYourSite && response.status != 'connected') {
// Redirect user or hide login button
}
})
Ref: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

Facebook C# SDK for Facebook Connect

How can I use Facebook C# SDK for facebook connect using ASP.NET?
What I am trying to do is:
Provide a "Login with Facebook" button.
Once the user clicks on Login button, get the access token on server side and sign in to my website.
Most articles (I found through google or SO) said use Facebook Javascript SDK for Log in and Authentication and then get the Access token from cookies created on web browser.
What I did so far:
Used Facebook login button in .aspx page with the below code.
<fb:login-button onlogin="window.location.reload();" perms="offline_access">Login with Facebook</fb:login-button>
Problems I am having:
When I click log in button on MY PAGE a window will pop up to log in to facebook. MY PAGE is supposed to reload when I login to facebook but it reloads even I click on Cancel button or close the pop up window. What I need is reloading MY PAGE only when I log in.
From the above step: If I log in and MY PAGE reloads perfectly. In code behind (Page load event) I can see the cookie created and it has the information (access token) what I needed. And from here I want to use Facebook C# SDK to get user information. how to do ?
I used Facebook C# SDK 3 months ago for developing a canvas application in Facebook. The documentation and examples listed on Codeplex are for Apps on Facebook (correct me if I missed to see facebook connect examples). Also, there was a link to documentation which lists all the Facebook C# SDK classes but I could not see that now. Please provide me the link if you know.
Any help will be greatly appreciated.
Thank you.
http://blog.prabir.me/post/Facebook-CSharp-SDK-Writing-your-First-Facebook-Application-v6.aspx
But there is one issue I am not using
parameters.response_type = "token";
Instead of that i have function to update Token
public static void UpdateToken()
{
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = AppId,
client_secret = AppSecret,
redirect_uri = Url,
code = FacebookUtils.FacebookData.Code
});
FacebookData.AccessToken = result.access_token;
}

Display a static Facebook login button image without using FBML

Is there a way or a link to a static image url to display the Facebook "Login with Facebook" button instead of the "Connect with Facebook" button? This seems to be the only link I can find for Connect with Facebook. I am able to generate a "Login with Facebook" button using FBML markup fb:login_button but in this case, I'm generating a login url link (in order to direct user through to a touch-enabled Facebook login interface -display=touch).
I found this image set very useful.
social buttons as images
You can!
First, create the link you want.
Login!
Or you can use an image. They are floating around the web.
<img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif">
Then, your myfunc() looks like this.
function myfunc() {
FB.login(function(response) {
if (response.session) {
if (response.perms) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
} else {
// user is logged in, but did not grant any permissions
}
} else {
// user is not logged in
}
}, {perms:'offline_access,read_stream'});
}
Few more notes:
You will of course need the other standard Facebook setup, FB.init(), etc.
onclick() is of course bad Javascript. You can tidy up with jQuery or whatnot.
Foursquare does this and has a nice Facebook implementation. Pick it apart. Notice that unlike many other sites, you can log out of Foursquare without logging out of Facebook and vice-versa.
Turns out, there's no way.
You can only generate FB Login buttons with FBML and specifying a custom text. All static Facebook images use the words "Connect" instead of "Login".
I took a screenshot of the Login button instead :).