page authentication to specific pages - facebook

In my web site, I want to ask the users for permission to manage their pages.
I saw in the documentation that I need to use the following:
https://www.facebook.com/dialog/oauth?client_id=MY_ID&redirect_uri=MY_URL&scope=manage_pages&response_type=token
However, I retrieve back a list of pages which are manages by the user.
Is there a way that inside the auth dialog the user will see list of pages managed by him so he could confirm only those that he allows?
I also don't know what are the pages id, and prefer not to call a method where I need to specify the page id, but to get a token and page id from what he has already selected.

In the old authorization dialogs there was a drop-down so the user can specify which pages they want to allow. However, that is now deprecated and the new dialog grants every page as you have found out. Basically, your app can show the user which pages they currently have under their management (display list from data return for HTTP Get /me/accounts) and let them choose.

Related

Facebook API: Problem accessing multiple pages from my App via Pages API

Premise:
After solving the mystery of the permanent token access, I have been able to post on my Readerly.Ink page from my app.
Problem:
My app, however, is supposed to post on multiple pages, depending on the language of the content. Hence, I today created the other pages (Readerly - Italiano, Readerly - English etc) but I cannot see them through the app!
Even if i GET /me/accounts, the original/first Readerly.Ink page is all I see. I also tried: /new-page-id?fields=access_token&access_token=your-user-access-token (as per instructions of the Pages API) - but I get an error! :-(
Question:
How do I add the new pages to the app?
Or do I need to create a different app for each page?
As far as I can tell, I created the new pages exactly as I created the first one (I'm the admin) and I added them all to my business account.
Please advise. Thanks
Or do I need to create a different app for each page?
No, you don't need to do that. An app is still able to manage multiple pages.
It used to be that you just granted an app access to manage all pages you have admin access to. But since that is obviously a bit broad and risky, Facebook has since changed things - users can specify which of their pages they actually want an app to have access to.
You get asked for that on the login dialog, when the permission is initially requested - but that list does not auto-update later to include any pages you created after that happened.
Currently, there does not seem to be any more practical procedure to get the new pages included, than removing the granted permission, and then asking for it again - upon which the user will be asked to chose which of their current set of pages they want to grant access to again.
For a quick fix, you can use Graph API Explorer - use the "get token" functionality, remove the granted manage_pages permission, and then ask for it again.
For a public facing app that has other people manage their own pages, probably such a step should be implemented within the app - remove the permission via API when necessary, then send them through the login flow again. (Might need to use the reauthenticate parameter at this point.)

How to get user likes in Facebook before asking permissions

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.)

Tracking user activities on facebook

I've created a Facebook page and implemented an application for it too. Now, my aim is that, a user must like and share page with at least one friend to be able to participate/to get access to the app and consequently use it (play the game). Or simply force a user to like and share the page. Can you please tell me if this is even possible and how it can be achieved?
When user visits your Facebook page, you receive signed_request , which contains some information about the user, including whether or not the user liked your page. For share, you will probably need to implement send dialog. In documentation it is said that user takes action (send or cancel) he will be redirected to url you set up, and if the action was "cancel", there will be an error.
So you will probably need to create db where you store user id and whether or not he shared your page before (since you can check if he liked the page at any time).

how to make users to manage their facebook pages in my website for adding some custom landing tabs?

how to make users to manage their facebook pages in my website for adding some custom landing tabs which i created in my webpage.when are user clicks on that custom tab, it should generate a dialog box or facebook API , with the list of pages which the current user has created and he should be able to select either of one page and that page should redirect him to that selected page in facebook with that custom tab.. Please developers help out me with some coding.
for example:follow this site hyly...
i was stucked up with this problem from last 1 month..hope you will make me to overcome this problem...
To retrieve the current pages a user administer you need the manage_pages permission and then to query: /me/accounts
Then you can install an app into a page by issuing a HTTP POST to PAGE_ID/tabs (example)
No one will build (code) an app for you. This community is about solving technical issues, i.e. you have done all the work and stuck in some points which you need help with.

Hide a Facebook tab based on user's location

We're developing a Canvas app that will have a tab when implemented on the fan page. The Tab will have the like gate. What we want to do, is restrict access based on location. So, Facebook users outside of the US wouldn't see the tab when the go the fan page.
This blog posts speaks to showing users different content based on location (http://developers.facebook.com/blog/post/394), but i don't want them to see the tab at all.
Any thoughts?
To set demographic restrictions (i.e., location, age, etc.) issue an HTTP POST with an app access token to
https://graph.facebook.com/APP_ID?restrictions={“RESTRICTION_TYPE:VALUE”, …}
ie:
https://graph.facebook.com/APP_ID?restrictions={"location":"US"}
Users who do not pass the restrictions will not see the tab.
More information at: Facebook Developer Blog & Graph API: Application.
When an application is accessed as a Tab on a Page (iFrame) Facebook Passes a signed request (http://developers.facebook.com/docs/authentication/signed_request). You would be able to use that data to get the user's location. However, it might need further authentication to get that information.
Please refer to this question for a hack to find the user location through their IP:
Getting user location on Facebook page tab
Anyway, as far as I know, you cannot remove the application all together, you have to show up 'some content' for the users who load the tab. I suggest that if you want to restrict page content to use the country restriction for the entire page. However, it might be impractical for your use case.