I have a client who wants to have the user liked his app before asking for permissions.
For users not having defined advanced security settings in their profiles this is possible, but I have occasions that I must ask for user_likes permissions to get that info so this is a dead end.
One solution could be to have my own like button in the page and register FB.event.subsribe to collect the info, but because the app will be used in a page tab (where a like button is already displayed by FB on top) this would be ugly and confusing.
Any ideas?
Within a page tab app, you get the info whether the viewing user liked the page already or not in the signed_request. (Since it is POSTed to your app on initial load into the iframe, you can only access it server-side.)
For how to parse it, see here: https://developers.facebook.com/docs/facebook-login/using-login-with-games#parsingsr
(If you are using the PHP SDK, that has a method to get it parsed implemented already.)
Related
I'm using Facebook::Graph and any time a page is loaded, I would like to detect server-side if a user has liked a certain page or not. I can't find in the documentation how to do this though. Is it possible to do this without sending the user ID to my server-side script? Because I know using the javascript SDK you can check this, but I feel like it might be different with a server-side API.
Not sure what you mean with "anytime a page is loaded"... I guess you mean an page of an App? If so, you need the user_likes permission to be able to get the information on the User's likes.
If you're using a Page Tab App, then you could get this info out of the signed_request which is passed to the App once the User accesses it from the Facebook Page Tab. See https://developers.facebook.com/docs/reference/login/signed-request/ The indicator is in the page.liked field.
I want my application to have two spare screens, one for the non Fan user (the ones that didn't press the button like) and one for the fans. How can I do that without asking the users to authorize my app? Do I have to use pages or page tabs first? or something else?
I tried with JS SDK and $_REQUEST["signed_request"] but there is no info if the user "likes" the app. I also tried FQL methods, but the most tables ask for the user_likes permission.
I'm totally lost with that and any help would be gratefull.
You can get this from the signed_request parameter, which is added to the request URL for your app on the page tab or canvas URL you provided. The signed_request param contains JSON data which includes the id of the page your app is installed on, and an additional liked field if the user has already liked the page. You can use this field to redirect users to the appropriate view for your app.
See the section labelled "Integrating with Facebook APIs" at https://developers.facebook.com/docs/appsonfacebook/pagetabs/ for more info.
I am trying to integrate my site with FB. So I have begun with registration plugin. My question is: where FB is saving the registered data, because when I am already registered on my site via FB registration plugin and viewing registration form again FB informs me that I am already registered. I could not find any information about it in user profile or in my app panel.
Thx for advise. If something is not clear I will be glad to explain my problem once again.
Check out the signed_request that Facebook is sending to your app via the redirect_uri (which is a page somewhere within your Site URL). It will have the encoded information for that user.
When you say "integrate my site with FB", I assume you mean "let people authenticate on my site by authenticating on Facebook ?".
I think there is all the info there :
https://developers.facebook.com/docs/guides/web/#login
https://developers.facebook.com/docs/authentication
EDIT : regarding the "http://developers.facebook.com/docs/plugins/registration/" example ; I can not say it authoritavely since I don't have the code, but I think what happens is that :
The registration form is in a iframe, showing a page that is generated on the server side (maybe, your server)
If you are not logged in, the form is not filled
There is a "login with facebook" that opens a pop-up with a page (from Facebook site) that has an extra param called "redirect-url" ; this will be a url or your site
When the user enters it's credentials, on the registration form that is posted to Facebook, they check the username/password, and when done, they call the "redirect-url" (again, a URL from your site) and pass the info in this (in this case, the redirect is configured to get a number of fields (name, birthday, location, etc...)
Your site gets the info in the form of a "signed_request" (see the section "Reading the Data"). In this case, it will render the same "Registration" page, except I would guess that on the server-side, some fields have been filled with the info provided by FB's signed_request.
The trick is that in this example, everything happens in an iframe - I'm not sure how this is mandatory.
Now, about the question "If I am already logged in FB, and I go to the Registration form, how does my info get in the form ?", I can only suppose that FB sets a number of cookies when you log in, that client site can use - but I agree with you that the documentation is not extremely clear about that. Probably, it's suppose to be hidden by FB's API, but the doc does clearly point to which one (at least on this page).
Again, I'm just speculating from the doc and tinkering with the requests made on the pages (and experience with similar oauth-y authentication schemes) ; hopefully someone with an actual application can give you more info.
Hoping this helped - sorry if it did not. Good luck with your dev.
PH
I want to create an iFrame Tab App for Facebook. I am planning on having a share button, so the user can share the tab app. If the user has successfully shared the tab app (= left a post on his wall which is defined by the app) I want to redirect him to let's say www.example.com/user-has-shared.
The way I understand this (http://developers.facebook.com/docs/reference/dialogs/feed/), this should be possible using the redirect_uri parameter.
However, when the user opens the dialog and doesn't click on "publish" but on "skip" instead, he is still redirected to the same page as defined. But I don't want to redirect users who have skipped publishing.
Any ideas? Thanks!
Using PHP by the way.
I'm not convinced that what you're asking for is possible, and it definitely isn't nice so that's fortunate. From the docs, redirect_uri redirects after any button in the dialog is clicked. Again, this is good.
You shouldn't be doing anything that requires the user post on their wall. While user advertising is nice, making it mandatory is frustrating and many of your users would be frustrated. A better method would be to build an app that people WANT to talk about! ;)
EDIT: Ignore my puffery there, this is totally possible. You check for $_REQUEST[post_id] on the redirect_uri'd page. More details in the comments.
I can't seem to find exactly what I'm looking for. We're trying to build an app to run solely on a Facebook Page. We want to show a landing page if they don't Like the page, and the contest entry form if they do. This functionality works.
Before showing the contest entry form, we'd like to authenticate the user viewing the app so that they can just hit "Enter the contest!" and we can automatically pull a name/email address.
Any of the methods of authentication I've seen described, including through the Facebook Developer docs, don't work at all.
I saw something that said they need to interact with the app first, then you can get the id, but that doesn't work either. I also don't get the page id passed with the signed request.
Its also pretty unclear whether I should be using an iframe or just FBML.
Could anyone point me in the right direction, please? Thanks!
You need to create a fan page and add the FBML plugin to that page, then you will need to insert a short code that will determine if a facebook user has clicked 'Like' or not and by determining that you will decide weather to display the content of the landing page or not (using an iframe). You will probably like to also set the FBML box that you create as the default view for members who didn't press the 'Like' button yet, you can change the default view in your fan page settings.
On the iframe, you will need to use the Facebook API if you want to retrieve any user information from Facebook, for that, you will need to register a new application with Facebook. Go to developers.facebook.com for the API integration and app registration.
Also, what do you mean when you say:
Any of the methods of authentication
I've seen described, including through
the Facebook Developer docs, don't
work at all.
Well, it appears you can't do it that way. The client was very specific in wanting that functionality but we ended up convincing them to go for a redirect to the canvas page to have the app authorized and the contest entered instead.