Facebook Graph API - Why Don't Interests Match? - facebook-graph-api

So, I'm quite flummoxed by this one. Please help if you can.
Let's say I pull from the Facebook Graph API for the following user: https://graph.facebook.com/zeeshan949/
I get:
{
"id": "657563147",
"name": "Zeeshan Ahmad",
"first_name": "Zeeshan",
"last_name": "Ahmad",
"link": "http://www.facebook.com/zeeshan949",
"username": "zeeshan949",
"gender": "male",
"locale": "en_US"
}
But ... if I'm logged out of Facebook and go to his profile http://www.facebook.com/zeeshan949 I see all his interests. Even if I'm logged out.
Am I missing something basic with the Graph API? What gives? How do I access all the other data?

That's intended behavior, not all user data (even public) available via API without approval of user (or sometimes his friend) by granting permissions to access specific information.
See documentation for user object and permissions documentation.

Related

What permissions are needed to call /{page-id}/ads_posts on Facebook Graph API?

I'm trying to list the Ads for a Facebook Page using the Graph API /{page-id}/ads_posts endpoint, but I get a permissions when I try to.
Using the Graph API Explorer, I generate an Page Access Token with those permissions: email, read_insights, manages_pages, pages_show_list, ads_read, business_management, instagram_basic, instagram_manage_insights and public_profile.
I'm an admin on the Page itself, the attached Business Manager and on the corresponding Ad Account.
Every time I try to call the /{page-id}/ads_posts, I receive
{
"error": {
"message": "(#200) Not enough permission to call this endpoint",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "XXXXX"
}
}
I can't find any help on the Facebook documentation or Google, given that the error isn't really meaningful (in some cases, I get a message saying that a specific permissions is missing, but not here). Anyone can help ?
EDIT: I tried to add the ads_management permission too, without success.
You need to add those pages to your app that is in development mode (https://www.facebook.com/settings?tab=business_tools).

Accessing users friends work history using GRAPH API 2.3

How can I get the users friends work history? Currently I tried this in the Graph api explorer:
GET /me/taggable_friends?fields=id,name,work&acess_token...
and the query returns the friends, but don't show any job.
The response returns me somethin like this:
"data": [
{
"id": "<some-long-string>",
"name": "<name>"
},
I tried to do this:
GET /<the-some-long-string>...
And the response says me that the user id is incorrect. Googling I didn't found anything :'(
Thank you!!!
From Facebook Developers:
"message": "(#10) To use taggable_friends on behalf of people who are
not admins, developers and testers of your app, your use of this
endpoint must be reviewed and approved by Facebook. To submit this
feature for review please read our documentation on reviewable
features: https://developers.facebook.com/docs/apps/review"

Facebook ad account group API access not correct on Facebook's site

I'm trying to build an application that will help manage different ad accounts for different customers (multiple businesses, so it has to handle multiple ad accounts). I'm looking at the ads API documentation for ad account groups, and the examples aren't working in the graph API explorer. Things like GET requests to
https://graph.facebook.com/v2.4/<AD_ACCOUNT_GROUP_ID>/users
(from Facebook's documentation here) are returning the following error:
{
"error": {
"message": "(#275) Ad account cannot be determined for this request",
"type": "OAuthException",
"code": 275
}
}
As best as I can tell, the documentation is incorrect - I think it can't tell the difference between an ad account ID and an ad group ID (I know this pattern is also used for things like managing custom audiences which is why I'm guessing it thinks it should be seeing an add account ID). Is there a better guide on updating ad account group membership via the API I can reference, or an endpoint I can substitute in for Facebook's official documentation?
First off please note at this time, you can still use v2.3 Facebook graph calls, prior versions have been deprecated by Facebook.
You will get this error. If you try older graph versions:
{
"error": {
"message": "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version.",
"type": "OAuthException",
"code": 2635
}
}
At the time of this writing you can use v2.3 calls and it still works.
Next I presume you want to know all the users, within accounts so the first thing to do is to get the list of accounts... Then iterate through each.. on an ad account basis.
Look up the api call to get a list of ad accounts, for a Facebook user id.
You will need the ad_read permission on the token in order to get the list.
Your api call should then look like this to get the users on each account.
Notice I put act_ in front of the actual account id. This is required and tells Facebook you are dealing with an ad account.
https://graph.facebook.com/v2.3/act_999998730499999/users?access_token=CAZZZZZpCZBjEBAJmcyfqbcluGAJZCtqfv4kI6CtLC7JGHaJ7IO2ImGCfkQFZC9NXCAZC2CAbtEdQcWMYFpqsFAkgJVqNqjnKGQkMrukyl53WZBIdq7vofFYyxvaTJTsWVOQhWTrjNoox0QqRCt3vGaDsRGHLBFDxqKLfXOcDKfS1oppj1nDjKdPe2GHYrHirlBkhxWS95MNgW7ajZZZZZ
Note: I have added ZZZZZs and 9999s in places to disguise my actual account and token.
The token used must be the ad account holder's token for the app. The user must have authorized the app for the ad_read permission on this token creation for the call to work.
The result looks like this:
{
"data": [
{
"name": "Joe Programmer",
"permissions": [
1,
2,
3,
4,
5,
7
],
"role": 1001,
"id": "999995304499999"
}
]
}
When using the development access of the Facebook Ads API, you need to specify which adaccounts you are going to use and you must own the adaccounts.
See the following guide:
https://developers.facebook.com/docs/reference/ads-api/access#standard_accounts

why does posting to facebook page yield "user hasn't authorized the application"

I have read the fb docs and written code to publish a message to a facebook "page", however I am getting an error that I don't expect to see:
(#200) The user hasn't authorized the application to perform this action
Here's what I've done:
I set up a facebook application, which provides my APP_ID and
APP_SECRET.
I set up a test facebook "page". Let us refer to its fb id as PAGE_ID.
Used OAuth to get a USER_ACCESS_TOKEN with scope "publish_actions,manage_pages" for the user. I accepted the permissions requested by my app when redirected to the facebook auth page.
I did a GET on https://graph.facebook.com/me/accounts using the USER_ACCESS_TOKEN, and I get back a list of pages I administrate, including the one I want to post to.
This block of data for my page looks like:
{
"data": [
{
"category": "Community",
"name": "My Generic Test Page",
"access_token": PAGE_ACCESS_TOKEN,
"id": PAGE_ID,
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
....
]
}
Then I use the PAGE_ACCESS_TOKEN to post a message to the page:
I did a POST on https://graph.facebook.com/PAGE_ID/feed with a field message equal to This is a test post.
Facebook returns:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
Using the token debugger, I can confirm that my PAGE_ACCESS_TOKEN is valid, and has scopes: manage_pages and publish_actions.
Where am I missing authorizing the application? Do I need additional scopes? Did I miss clicking something on the facebook authorization screen? Is there a setting on the app I am missing? After days of debugging this, I must be blind to the problem. :-|
You should add permission called status_update, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=status_update&from_login=1&m_sess=1&rcount=1
and i'm able post to page i liked with the access token i get just now:
If you want to post as the admin of the page, you're require both manage_pages and status_update permissions, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=manage_pages%2Cstatus_update&from_login=1&m_sess=1&rcount=1
Cheers
status_update is not used anymore. To publish on pages, I had to use both manage_pages and publish_pages.
Well, this seems to be a common mistake that most of us make while trying to do an activity in social netwroks. Before trying to put up an open graph action,You need to set the permissions in your initial authorization request . By default you only gain 'read-only' access to their basic information.
Settintg up permisson at teh time of authetication is a must for Facebook and LinkedIn APIs..
See the public_actions section in Facebook open graph permissions here and make relevant changes in the authorization code , and get your issue solved.
I found the best way to get a valid token and check permissions was via the Graph API Explorer BUT while Facebook's documentation is extensive it is not always the easiest to follow.
In the explorer you have to look at both:
The Application Currently at the top and quite subtle, I missed this for ages.
Get Token Dropdown What you click to get a Token, when you click the arrow you can choose pages and other items you have access to for selecting a token for.

Access_token for graph api calls in JavaScript

I am trying to pull in and display the wall posts and comments from a public Facebook page on my client's webpage using JavaScript. I know I need an access_token, but the problem is it expires every so often. It seems I would need to dynamically get the access_token to avoid that issue. Does anyone know of a way to do this client-side?
Short answer:
If the page is really public, you don't need an access token at all. For instance,
http://graph.facebook.com/19292868552
{
"id": "19292868552",
"name": "Facebook Platform",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg",
"link": "http://www.facebook.com/platform",
"likes": 3922010,
"category": "Product/service",
"website": "http://developers.facebook.com",
"username": "platform",
"founded": "2007",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.",
"mission": "To make the web more open and social.",
"about": "We're building the social web. Get the latest here: developers.facebook.com ",
"talking_about_count": 74536
}
Longer answer, if you are using a particular user's access token to perform actions on their behalf, you might consider asking for "offline access" so that the token won't expire. See https://developers.facebook.com/docs/reference/api/permissions/ for more information about how to ask for this permission.