Facebook API: (#100) No matching user found - facebook

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/

Related

FB Graph API is not returning user object in post's comments, likes, reactions

I've FacebookApp [ type: business ] which fetches all posts, post-comments, and post-likes from the owned Facebook pages.
Verified permissions are ['pages_show_list', 'pages_read_user_content']
When I'm fetching the post and their comments/likes then the user-object is missing in the response body.
Sample JSON
API : https://graph.facebook.com/v2.12/<PAGE-ID>/? \
fields=posts{message, comments{message, from{id, name, link}},reactions{from{id, name, link}}} \
&access_token={{pagetoken}}
response body sample :
...
"message": "For cancer awareness month we are sharing stories of survivors! \n\nManorama is sharing story ... Cancer Campaign (India)",
"comments": {
"data": [
{
"message": "Thank u so much to the entire team.",
"id": "420757949533461_421416076134315",
// USER OBJECT IS MISSING : [id, name]
},
{
"message": "Thank u for sharing ma's story with all!",
"id": "420757949533461_421407146135208",
// USER OBJECT IS MISSING : [id, name]
}
],
...
I'm not sure what is wrong with the above API call because the API call is working fine with TestPage and TestUser. Do I need to ask for some additional permissions from Facebook?
Facebook Graph api does not return user's name anymore by calling this endpoint.
There is one solution you can try: use hooks.
Set a page webhook to retrieve all the comments written on your page. Find the documentation here: https://developers.facebook.com/docs/pages/realtime
The comments' data you'll receive from facebook will contain a name

Missing attributes with Facebook Graph API Photo Node

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.

Is there a way to fully test “publish_actions” to comment (other user posts) without submitting app for review?

I created an app on the FB developer page, and correctly configured it to allow “publish_actions”. Also tested to comment my own posts using the graph API and everything went OK.
https://graph.facebook.com/v2.2/xxx/comment
Sending the field message “some comment” (as post)
The problem is whenever that “Comment ID” does not belong to me, for example a friend or a page post that I am trying to comment, I always get:
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200
}
}
(The token generation, and permission requests worked flawlessly, also even added all the permission available to test, but no luck)
Is there any way to test the comment function on other person post or page without submitting the app? Or is there a way to create “test” pages (as there is for test users) to test this?

Commenting on Facebook Page Ratings (Reviews) via Graph API

Long time lurker first time poster...
We are working with Facebooks API's to integrate into our web application and we are able to pull a Companies Page Rating via the {open_graph_story} parameter in the {page-id}/ratings section, however we cannot find a way to comment/reply to the rating. The documentation states:
"If a person has rated your page and a story has been generated, you can follow up with the person by posting to the story's comment node." (https://developers.facebook.com/docs/graph-api/reference/v2.0/page/ratings)
however when we pull the variables we retrieve no ID to reference for a comment. This is what we receive back from our authenticated account:
"data": [
{ "created_time": "2014-07-16T05:52:50+0000", "reviewer": { "id": "100000237096397", "name": "Romey Salazar" }, "rating": 5, "review_text": "Great job guys!!!!" } ],
Does anyone know how to retrieve the id for the rating itself so we can append a comment via API? Or some other way to reply/comment to a FB Page Rating?
Thanks!
When you have some ratings/review comments on your page and if you want to post comment to individual review comments as the Page Owner, you can follow the steps below.
1) Below request returns the json object of rating and reviews.
https://graph.facebook.com/v2.9/{YOUR_PAGE_ID}/ratings?field=open_graph_story&access_token={YOUR_PAGE_ACCESS_TOKEN}
The response json will contain ID field for each and every rating/review comments.
2) Using the ID, trigger the below request to post a comment on the rating as the Page Owner. You will need Page access token with manage_pages and publish_pages privilege.
https://graph.facebook.com/v2.9/{ID_OF_THE_RATING}/comments?message=Thanks for your rating&access_token={YOUR_PAGE_ACCESS_TOKEN}
These requests can be tested using Facebook Graph API Explorer
You need to request the open_graph_story field with the ratings endpoint. This will return the open_graph_story data which includes an id. You can then post to the comments endpoint of this story.
You have to make http get request on
https://graph.facebook.com/v2.9/{PageID}/ratings?fields=open_graph_story&access_token={PageAccessToken}
to get detailed response.
Make sure the parameter is "fields" not "field"

Can't get Facebook user id by Graph

I'm working on an iOS app and noticed that one user is not loaded when I do a requestForMyFriends.
After looking more into this it seems that the Graph API explorer also doesn't return anything for the particular Facebook user. It's a user and not a Fanpage or something.
So:
I've the page for example (which when I enter In my browser will bring up the Page nicely): https://www.facebook.com/user-name
https://graph.facebook.com/https://www.facebook.com/user-name
Will return:
{
id: "https://www.facebook.com/user-name"
}
https://graph.facebook.com/user-name
Will return:
{
error: {
message: "Unsupported get request.",
type: "GraphMethodException",
code: 100
}
}
http://findmyfacebookid.com/ wil return nothing.
The graph API will return:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I'm trying to reproduce this with my test Facebook account and put all restrictions to the max but I always get a nice result with a FacebookId.
My question:
What settings do I need to change to my test Facebook account to reproduce this problem?
"Unsupported GET Request" covers many situations, but at the root the message means you tried to request something via the API which is not available to you via the API
For a request which attempts to retrieve data about a known username or user ID the most likely reasons are:
User has blocked your app
User has disabled all platform apps in their privacy settings
User has deactivated their account
User has deleted their account
if i had to bet, I'd say it's the second one in this case
The problem is the parameter, you don't have to pass in the whole URL of a profile, just the username/profile-id.
For example: we want to get the info of Mark Zuckerberg. His Facebook username is zuck. The URL would be https://graph.facebook.com/zuck and will return the following output
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Using https://graph.facebook.com/4 (4 is the profile id of Mark Zuckerberg) would produce the same output.
Edit
After some further investigation it turned out that said user might have deactivated her account and that is why you see this error. I have used a testuser of one of my apps, went to Settings -> Security -> Deactivate my account and taxa, every request to the Graph API returned the result you're seeing.