Missing attributes with Facebook Graph API Photo Node - facebook

I have an access token with the manage_pages scope. Using this token, I call the endpoint specified here (GET /{page-id}/photos?type=uploaded).
The result is for some reason lacking all attributes except id and created_time. This is a part of the response:
"data": [
{
"created_time": "2018-10-30T18:12:31+0000",
"id": "1172525292900120"
},
{
"created_time": "2018-10-30T18:10:08+0000",
"id": "1172524459566870"
}
]
The docs says that data should contain "A list of Photo nodes". Looking at the photo node docs, it seems they have exactly what you'd expect.
My app does not have the permission Page Public Content Access yet. But according to their App Review section, it isn't needed for accessing my own page's content. And then again, I wouldn't even be able to get a list of photos if I didn't have access to the page.
While you are testing your app and before you submit it for review, your app can only access content on a Page for which the following is true: The person who holds the admin role for the Page also holds an admin, developer, or tester role on the app.
Why am I missing some attributes in the Photo nodes?

I had to specify which fields to retrieve like this: GET /{page-id}/photos?type=uploaded&fields=images.

Related

How to display "from" fields in comments via Facebook Graph API

I would like to find the id (app-scoped) for someone who has posted a comment on a public page.
For example, I get a list of recent posts/comments on the NY Times page via:
v2.11/nytimes/feed?fields=comments.limit(10){message,created_time,from},name,message,from&limit=2
The data returned looks like this:
"comments": {
"data": [
{
"message": "Wouldn’t know. Not paying $13/mo for this.",
"created_time": "2017-12-10T05:57:18+0000",
"id": "10151412260164999_10151414049324999"
}
],
There is no from field. The same is also true if I attempt to view the comment directly using it's id with
v2.11/10151412260164999_10151414049324999?fields=from,message,created_time
I have tried using the Facebook Graph API Explorer, using both my User Token, as well as an App Token.
Since v2.11 of the Graph API, you need a Page Token to get user data of comments: https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90
User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.
In other words: You can only get user information if you manage the Page.
Edit: Since the latests update in the Graph API, you have to get the App reviewed and you must go through Business Verification or Individual Verification. (thanx #Guiman04)
Please check whether you are using the accessToken for the page you are trying to get data from, i had same issue, and was resolved by using the correct accessToken for the page.

Facebook API: (#100) No matching user found

I spent whole days to try to figure out this error, I also notice there are similar questions with the same message, but I'm totally not sure I find the answer in there, so if someone could point out or give any tip into my problem, I totally appreciate that.
I'm making the request to send a message from a Facebook page A to a user X (by userId) who makes a comment on a post of FB Page A, through a testing FB App name MyApp. I am trying this on Facebook Graph Explorer.
I got the user Id by fetch the list of comments in a post in the Facebook Page, but I totally could not send the message.
Here is the error
{
"error": {
"message": "(#100) No matching user found",
"type": "OAuthException",
"code": 100,
"error_subcode": 2018001,
"fbtrace_id": "H3yMO0RWaDy"
}
}
Here is the my track
MyApp has been setup webhook OK, because it is not published yet for the testing purpose (unapproved app), so I have to add the user X account into tester pool of MyApp (the message that I try to send is also this user X)
I logged into user X to make a comment on a post in the FB Page A
On Graph Explorer, I selected Application: MyApp, and get Page Access Token of FB Page A, I performed two following requests
3.1 /{page_id}_{post_id}?fields=comments
With this, I can get the list of existing comments in FB Page A, here is the output:
{
"comments": {
"data": [
{
"created_time": "...",
"from": {
"name": "User X",
"id": "123456789" // this is the user Id that I would take to send the message to
},
"message": "Sample comment from User X",
"id": "..." // {page_id}_{post_id}
}
],
"paging": {
....
}
},
"id": "..." // {page_id}_{post_id
}
}
3.2 {page_id}/messages: I am trying to send a message from FB Page A to user X with the user Id that I got from 3.1 step
recipient: {id: "123456789"} // there seems be a problem with this id that I got from step 3.1, FB cannot find the user id with this number
message: {text: "hello"}
I'm also acknowledged about the app/page scoped id for user.
I have already subscribed MyApp to the FB Page A with API (/{page_id}/subscribed_apps)
Facebook API v2.10
I have no clue what's wrong.
I figured it out. Facebook Messenger Platform use paged scope user id, but what I were using is app scope id. They are different.
Here is official doc from Facebook about how to get the paged scope id
The id must be an ID that was retrieved through the Messenger entry
points or through the Messenger webhooks (e.g., a person may discover
your business in Messenger and start a conversation from there.
These IDs are page-scoped IDs (PSID). This means that the IDs are
unique for a given page.
If you have an existing Facebook Login integration, user IDs are
app-scoped and will not work with the Messenger platform.
The solution is subscribing MyApp to the FB Page (what I've already done) to get the webhook to work, where I will get the page scope id from the message of user.
Furthermore, detail of how to setup the subscription found here
http://ukimiawz.github.io/facebook/2015/08/12/webhook-facebook-subscriptions/

How to get a Facebook access token that has enough rights to get the posts in which you're tagged in?

The Facebook posts in which you're tagged in - using #Name - appear in your wall feed.
A friend of mine posted a link and tagged me in it:
On the Graph API documentation, when I click on my wall feed link (Ctrl + F: Profile feed), I'm able to see this post:
...
{
"id": "XXX",
"from": {
"name": "XXX",
"id": "XXX"
},
"to": {
"data": [
{
"name": "XXX",
"id": "XXX"
},
{
"name": "Christophe Maillard",
"id": "XXX"
}
]
},
"message": "The startup Guide (cc XXX, Christophe Maillard)",
"link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
"name": "How to Get to Your First 1,000 Users",
"caption": "mashable.com",
"description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
...
}
...
The URL of this feed is https://graph.facebook.com/me/feed?access_token=XXX.
When copy/pasting the given access token - the one replaced by XXX in the URL above - within the debugger, I get something like this:
As we can see, the access token is generated by the app Test_console which used quite a lot of scopes.
Then, I go to the Graph API Explorer, I generate an access token using the Get Access Token button, and I specify all the scopes the debugger gave me, i.e. the ones the Test_console app used to generate its working access token. Finally, I access the URL me/feed by submitting the GET request. The problem: I can't see the post in question in which I'm tagged in with the explorer.
I also have my own app, and it reacts exactly like the Graph API Explorer: I can't find that post in my wall feed using the Graph API as well.
Obviously, it's possible to get the posts in which you're tagged in using the Graph API, because the Test_console app is able to generate an appropriate access token. But how can I get such an access token for my own app?
You need to grant the appropriate permissions for your app. In the graph api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me switch to your app in the applications field (top right) to see what permissions that currently grants your app (by clicking the "get access token" button again). Then make sure you add in the correct one (i think it's read_stream you're after ) https://developers.facebook.com/docs/authentication/permissions/

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.

How do I add a custom tab to a Facebook application profile page programmatically?

I am able to add custom tabs to my Facebook pages, by using the Graph API,
[https://graph.facebook.com/page_id/tabs] and using HTTP POST.
However, I am unable to add custom tabs to my Facebook application's profile page. Infact the API, [https://graph.facebook.com/page_id/tabs], with HTTP GET also fails.
(I mean, I cannot even get the tabs for my Facebook application's profile page with the API.)
What am I doing wrong?
Here I am listing what I am trying to do:
I get an access_token (say a1) for a user (admin_user) using the manage_pages permission.
With this access_token (a1), I use Graph API, >[https://graph.facebook.com/me/accounts] and get back a list of pages (pages and application profile pages):
{
"data": [
{
"name": "Bg",
"access_token": "***",
"category": "Industrials",
"id": "*****"
},
{
"name": "Testapp2Pip",
"access_token": "*******",
"category": "Application",
"id": "***"
},
Now I use the Graph API, [https://graph.facebook.com/page_id/tabs]
Case 1. If I use the page_id for the background page (which is a normal page) and the corresponding access_token, I get back the tabs for the page.
Case 2. If I use the page_id for the Testapp2Pip page (which is an application profile page) and the corresponding access_token, I get an error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException"
}
}
What am I doing wrong here? How do I get the tabs for an application profile page? Also, I would actually want to add custom tabs to the application profile page by using Graph API.
Have you added the app to the app profile page, and/or double checked that it is added as an app? It seems odd, but you can add/remove the app from the apps own page. I'm guessing if the app isn't added, then it wouldn't have access to the page information.
An alternative option is to get an access token for the application, not the current user. This page has instructions for getting an access token for the app, instead of the user. Scroll down to the "App Login" section.
http://developers.facebook.com/docs/authentication/
Okay, so this is a bug. I have filed the bug with Facebook.