I would like to implement the Facebook "Continue as {Name}" feature as described on this page: https://developers.facebook.com/docs/facebook-login/web/login-button/
However, my current implementation does not use the <div class="fb-login-button" ...></div> method as shown in that page. I login using the FB SDK manually. I would like to keep this implementation if possible.
My question is: is it possible to retrieve the users' name without asking for permission from my app?
Related
When I did InspectElement on Pinterest's facebook login button, I saw this:
<a href="/facebook/register/?scope=email,user_likes,user_birthday,publish_actions" class="BigButton facebook" data-network="facebook" data-callback-url="/facebook/register/">
<span class="logo"></span>
Facebook
</a>
I could not found anything related to calling Facebook JS SDK with APP_ID, setting cookie, session etc.
How is it implemented here? What are data-network and data-callback-url tags? Are they custom tags developed by Pinterest's developers?
How can implement with the same cleaner approach?
Pinterest is using server-side login. Hence, you will not find FB's client-side JS SDK based FB.login calls. However, they seem to be using the JS SDK for getting login status and that's why they have FB.init calls.
These 'data-' attributes are part of HTML5. A quick search will help you with documents on how to use it with JS/JQuery and how it simplifies the code. In their case, they are using the values for 'network' and 'callback-url' in JS to handle something (I don't see the code that you mention above to comment further).
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/
I am hosting a Facebook app on Google app engine, I need to make sure the user is logged into facebook before anything.
What I can currently do is display facebook's log in button using fbxml, but I prefer the user would be redirected to Facebook's log in page if he wasn't logged in, then back to my app's main page, this way I can make sure that the user is logged in before doing anything.
I am new to Facebook apps, I read here that I can redirect the user to
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
in order to authenticate him. But using GAE's self.redirect(url) doesn't work, the page stays the same. I was hoping I could do something like this in my handler:
if u'signed_request' in self.request.POST:
facebook.load_signed_request(self.request.get('signed_request'))
if not facebook.user_id:
self.redirect("https://www.facebook.com/dialog/oauth?"+
"client_id={0}&redirect_uri={1}"
.format(FACEBOOK_APP_ID, EXTERNAL_HREF))
return
but as i said earlier this doesn't work.
I'm assuming by 'Facebook App' you mean a Canvas App - so something that will live at https://apps.facebook.com/YOUR_NAMESPACE from a user perspective?
If so, you'll need to add the redirect via Javascript using window.top, as your app is loaded in an iframe. See https://developers.facebook.com/docs/appsonfacebook/tutorial/ and search for 'top', then view the example toward the end of the page.
There are also good examples on the Php Sdk that facebook provides. I like the with_js_sdk.php example. It runs seamlessly and is good to follow.
https://github.com/facebook/php-sdk
http://developers.facebook.com/docs/reference/php/
I am developing an application on facebook. My application also has an registration page. When a new user enters into our application I want the application to show the images of all his friends who are using this app. How do I accomplish this?
The solution to this problem requires that you use a Facebook Social Plugin.
You can't build your own registration form and show a user all his/her friends who are using your application before the user installs your application. This is because, in order to get a list of the user's friends, you have to have a valid access token - as this isn't public information.
There are 2 different social plugins you can use.
The simple "login" button which looks like the Facebook login button. (documentation here: http://developers.facebook.com/docs/reference/plugins/login/)
A registration form, which uses their users' Facebook profile to pre-populate some fields. You can also add fields to the form to get more information. (documentation here: http://developers.facebook.com/docs/plugins/registration/)
Both of these show the user pictures of the friends that are already connected/installed, and this is pretty much the only way you can pull this off before the user authorizes your application.
edit 5/20/2011
After browsing around the FB Social Plugin docs, I found another Social Plugin that you could possibly use if you didn't want to use the Facebook Registration Social Plugin. You can use the Facepile Plugin. This shows all the users' friends who have connected to your app, or page, or whatever you want..so you could build your own registration form and use this social plugin to achieve the friends photos result you were looking for.
I guess I see two solutions :
Simple, put a facebook like button "with faces" somewhere on your page, your users will then see the pictures of their friends who "liked" your page.
The option for showing friends pictures is show_faces="true"
Second option, that is a bit more difficult :
When a new user registers :
Save it's Facebook ID in a DB.
Get it's friend list using something like : https://graph.facebook.com/me/friends?access_token=...
Parse the returned JSON of its friends, and then compare with all the Facebook ID's you already have in your DB, you can find which friends are already in your systems, those are the friends you want to display, to get their pictures just use <img src="http://graph.facebook.com/USER_FACEBOOK_ID/picture?type=small"></img>
See more about getting friends of a user here : read about the "friends" connection.
the best way is to use facepile you need to add data-app-id and don't add data-href because if you will add data-href then system will check that url not your app so the facepile
div will look like this:
<div class="fb-facepile" data-app-id="YOUR_APP_ID" data-max-rows="1" data-colorscheme="light" data-size="small" data-show-count="true"></div>
I am using an IFrame application with XFBML and the new Javascript API.
I'd like to have a facebook application with multiple entry points. These will most likely represent different links coming from a fan page tab.
I can do this quite easily if the pages don't require authentication - for instance I can create several pages under the app and if a new user comes I can send them to any page:
http://apps.facebook.com/myapp/offers
http://apps.facebook.com/myapp/game
http://apps.facebook.com/myapp/products
The problem is that if I need to have authentication then once the user is authenticated they get redirected to my default post-authorization url.
Is there a way for a user that comes to /game to stay on /game after they are authenticated without redirecting.
I thought I could do it with the AJAX login form - but I cannot find out how to do that in a Facebook IFrame application.
I think the example using requirelogin only works for FBML.
<a href="http://apps.facebook.com/mysmiley" requirelogin=1> Welcome to my app</a>.
Is there a way to accomplish this with Facebook APIs - or will I have to do some kind of clever cookie handling?
You can use the facebook connect JS library inside of an iframe app and then redirect them to the appropriate url in javascript if they click allow. Best to go to the Facebook dev docs on the Javascript SDK on Fb:login here: http://developers.facebook.com/docs/reference/javascript/
Basically if the login is successful, you will get a callback where you should redirect them in javascript by using window.top.location = 'yoururlhere';