Facebook Graph API call not working from outside - facebook

I created a web page to login to Facebook and then once logged in, create a session which stores the access token and also the user id. And then I redirect the user to a profile page where it pulls the information from user's facebook posts via a Graph API call and then presents the information. I'm using PHP to get the Graph API.
It's working fine on my local machine and I can see the data just as I want. But when I access the same link from outside my home network, It displays a blank page. I can still login from outside the home network so that piece of code works fine, but it is unable to pull the user_posts. There's nothing wrong with the code as far as I understand otherwise I won't be able to access the link even from my local network.
I tried many different solutions, added a whitelist of IPaddresses (but it may be that I'm not adding them in the correct place). I'm at a total loss. Has someone experienced a similar situation? If adding the specific ip addresses would help, where do I add them exactly. There are so many confusing fields in the Facebook developers settings.
Any help is much appreciated.

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 all the pictures my facebook page is tagged in?

I have a page and I want to run a contest for that page I am the admin of that page. I want people to post pictures on their wall and tag my page in their picture. at the end i want to get all the pictures my page is tagged in using graph api. Is there a way to do this ?. I have tried all the things. I created a app the i got the access token with all the permissions including manage_pages. then i got the page access toke using me/accounts endpoint. then using that access token me/photos/tagged. no luck so far. I am not getting all the pictures.
A little help would be appreciated Thanks.
Your question (and additional info in the comments) suggests that this stems from how Facebook deals with privacy. There are many scenarios in which using a page access token people cannot access content that is owned by a personal profile, even if the admin (personal profile) of the page owns that content.
If you have reason to believe that the API is not returning all the information that it should, you can file a bug with Facebook. If you do, please be sure to include all the necessary steps for them to reproduce the issue or they won't be able to fix it.

Facebook Graph Api me/home Seems To Return Same as me/feed

I know there have already been a lot of questions asked about replicating the users home feed and using me/home, but my question is slightly different.
A few months ago I wrote code to authenticate with Facebook (get user access token) and then retrieve their home feed with me/home. This worked fine at the time as far as I can recall. I've just gone back to the code today, and it doesn't appear to work. The result I get back looks almost the same as me/feed, which is to say it is almost entirely posts from the same account and not posts from 'friends'. Just one post from someone else, a change to their profile pic, shows up but the rest are all 'self posts'.
This only happens with tokens for my own app. If I use graph explorer using the same token, I get the same result. If I use graph explorer with it's own token then it shows me something much more like the actual home feed on the Facebook site. Generating new tokens doesn't help. I have checked the permissions on the tokens used are the same, in fact I even copied the permission list from the generated graph token into my app and re-authenticated, but it didn't help. If my app does the request, then I get almost nothing from other people from me/home. This is the same if I use myuserid/home. Makes no difference.
So my question is, why? Have Facebook changed something and is there a way to change my app so it gets a better version of the home feed?
Secondly, while researching this I've discovered posts saying read_stream won't be granted by Facebook to any app on any platform that has an 'official facebook app'. Does this mean I'm out of luck anyway, even if I get this working for testing purposes using the account that owns the app, I won't actually be able to publish it so others can use it?
Thanks.

How To Access The Graph API After Using A FB:Login-Button?

I'm sure I got this to work in the past, but for some reason I'm having trouble finding out how to do it now...
I have users logging into an application and granting permissions using the button provided by Facebook:
<fb:login-button perms="email,publish_stream">Login</fb:login-button>
Thereafter, suppose I want to try to post something to their wall. Do I need to extract an access code at the end of the login process? Is there a redirect-uri that the login process sends the access code to - if so I can't immediately find this for my app, where is it set? Facebook's Developers documentation is good to a point but ultimately frustrating for me... am I looking at the wrong section there?
Aha, looks like I've found it: Facebook automatically stores the details for the logged in user, including the access token, in a cookie called fbs_YOUR_APP_ID. So I should be able to get what I need out of that. As you were!

Facebook graph API returns empty data for a page

I have an application that is retrieving data from Facebook. Users authorize the application to read and write to their pages, and we read their data and post to it from our application. All interaction occurs via the PHP interface that Facebook supplies.
For the last few months our application has been performing this task flawlessly. However in recent days we have started noticing an issue with certain pages.
We go out and retrieve data for a specific page, and we no longer get any data. Instead Facebook returns us an empty result. This obviously causes problems in our application which needs to read this data.
We can still write data just fine.
I am at a point where I'm not sure what this could be. Any common scenarios or recent Graph API issues that could cause this?
This sounds odd. The only thing that comes to mind is that the page owner has put a restriction on the audience for their page, which would then require you to pass in an access token to access data about the page. An example would be a beer company that wants to limit access to their FB page to users that are older than 21. Since there is a restriction on who can access the page content, we enforce that restriction on the FB platform. In this case you would need to pass in the access_token of a user who is 21 or older to access the page details via the graph api.
Adding to Jeff's answer, I found that any kind of restriction whatsoever will return a blank data object. I was banging my head on every single setting on my company's page and found that we had it set to only show in certain countries (Manage Settings > Country Restrictions). Removing all of them from the list started to return all the data we needed.