How to get a user's friend list from graph api without authentication? - facebook

I can see a user's friend list in facebook.com but I can't get this by graph api. I use this fql in "Graph API Explorer" :
SELECT uid1 FROM friend WHERE uid2=100002756991450
but it tell me:
{
"error": {
"message": "Error validating access token: Session has expired at unix time 1358668800. The current unix time is 1358677687.",
"type": "OAuthException",
"code": 190,
"error_subcode": 463
}
}
How can I get a user's friend list without authentication?

This is Not due to authentication, this is because user's session has been expired, So generate new access token and use it.
You could get this error.
{
"error": {
"message": "Can't lookup all friends of 515977793 due to user's privacy settings.",
"type": "NoIndexFunctionException",
"code": 604
}
}
if user has a privacy.

Related

unable to post on facebook photos to groups and pages via graph-api

my app is in development
i am using below permissions:
"public_profile",
"publish_video",
"pages_show_list",
"pages_read_engagement",
"pages_manage_posts",
"publish_pages",
"user_managed_groups",
"groups_show_list",
"publish_to_groups",
"groups_access_member_info",
"publish_actions"
but on trying use the api to post photo in group and page i get below errors
https://graph.facebook.com/v12.0/{page-id}/photos?access_token=={token}&url={url.jpg}
error:
{
"error": {
"message": "(#200) The permission(s) publish_actions are not available. It has been deprecated. If you want to provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AW4L8qJL7HJWz9oTL7rk1IY"
}
}
https://graph.facebook.com/v12.0/{group-id}/photos?access_token={token}&url={url.jpg}
error:
{
"error": {
"message": "(#200) Insufficient permission to post to group",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AsV2H45AICb6G7D73aiedW4"
}
}
Can someone please help with this
Solution for page post
follow this url for details: access_token
using user access token get page access token, pass this page access token in above url for page post
curl --location --request GET 'https://graph.facebook.com/v12.0/{page-id}?access_token={user-access-token}&fields=access_token'

Facebook graphapi claim pages

I am trying to request access to a page with my business manager running this call in graphapi:
POST: {businessid}/client_pages?page_id={pageid}&permitted_roles=['ADVERTISER']
With my systemuser admin token as requested per documentation:
https://developers.facebook.com/docs/marketing-api/business-asset-management/guides/pages
this will result in an error
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "{traceid}"
}
}
Now i cant find anywhere in the documentation that i need further permissions than just being a systemuser and having access to the business.
My permission list on developer.facebook
I am missing a permission but i cant figure out which one, any ideas ? :)
Cheers

Send messages via Graph API stop working

Am testing this method via Facebook graph api explorer
https://developers.facebook.com/tools/explore
i chose my user and give him access to pages_messaging read_page_mailboxes manage_pages
then choose certain page and method {conversatio_id}/messages with POST request
and send parameter
message: "test test"
I got this response
{
"error": {
"message": "(#210) This call requires a Page access token.",
"type": "OAuthException",
"code": 210,
"fbtrace_id": "C+Xo8LCuuLW"
}
}
Facebook reference
https://developers.facebook.com/docs/graph-api/reference/v2.10/conversation/messages
This is issue reported in Facebook API and fixed now!
https://developers.facebook.com/bugs/261578841015508/

Facebook Open Graph event search

On Graph API Explorer I can do this search: search?q=Barcelona&type=event
But when I try the same with my app access token I get this error:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
The other searches work well.
UPDATE 2017-11-27:
As Facebook doesn't allow an event search based on location anymore, I'd recommend to use https://github.com/tobilg/facebook-events-by-location-core
Original answer:
Please refer to https://developers.facebook.com/docs/reference/api/search/#access_tokens
There, it's stated that all searches except for pages and places require an user access token.

Consult mailbox_folder Error (FQL)

I need to consult direct messages from a fan page, run the following FQL
https://graph.facebook.com/fql?q=select folder_id from mailbox_folder where viewer_id = <my fanpage id>&access_token=<My page access token>
but the request return the next error:
{
"error": {
"message": "(#606) You can only fetch messages for one user",
"type": "OAuthException",
"code": 606
}
}
How to fix it ?
Use the conversations endpoint in the Graph API
/PAGE_ID/conversations
https://developers.facebook.com/docs/reference/api/page/#conversations
I don't think there is an FQL equivalent for pages yet.