Facebook Graph API Search - Search for Groups - facebook

Its my First Question in Stack-overflow Community, I wish that i will get good response from all of you.
I was trying to work on Facebook Graph API to search for groups using below URL ......
https://graph.facebook.com/search?q=programming&type=group
According to new Documentation, it needs an access token, But I did not found any suitable Link from where i can get Facebook Groups Access Token.
Kindly help me to get the access token with some efficient procedure and Refined the above URL with access_token.
Thanks.

It just needs an access token, not specifically a group access token. append a user access token to the end of your query and it will work.
eg https://graph.facebook.com/search?q=programming&type=group&access_token=USERACCESSTOKEN returns
{
data: [
{
name: "Programmers,Developers",
privacy: "CLOSED",
id: "361338743928370"
},
{
name: "I am Programmer,I have no life.",
privacy: "OPEN",
id: "1840883746179186"
},
{
name: "Pojok Programmer",
privacy: "OPEN",
id: "444794115578165"
},
{
name: "Fitness Programming By CVG",
privacy: "CLOSED",
id: "416198445414413"
},
{
name: "freeCodeCamp Earth",
privacy: "OPEN",
id: "321090721625587"
},
{
name: "Learn Programming Basics and Latest Tricks ✪",
privacy: "CLOSED",
id: "320779011722495"
},
{
name: "Python Programming Language",
privacy: "OPEN",
id: "457660044251817"
}]}
You can retrieve a token for testing using the access token tool https://developers.facebook.com/tools/accesstoken/

Related

Rest API content language negotiation

I'm currently building an API where developers will be able to call and request a specific language thru the header. But I'm also developing an API client for the administrator (kind of alike a CMS).
For that client, I would like to be able to return all the available locales in one call.
So for example, an API public call (language=en) would return the following:
{
name: 'Steve',
description: 'My english description',
url: 'http://example.com'
}
But I would also be able to make a multilingual call to get the data for all locales:
{
name: 'Steve',
locales: {
en: {
description: 'My english description',
url: 'http://example.com'
},
fr: {
description: 'Ma description en français',
url: 'http://example.com/fr'
}
}
}
Is there any REST standard to achieve this and avoid having to make 2 API requests?
I would recommend something like
GET /users/steve
{
"name": "Steve",
"description": "My english description",
"url": "http://example.com"
}
with Accept-Language header set as en and
GET /multilang/users/steve
[
{
"lang": "en",
"content": {
"name": "Steve",
"description": "My english description",
"url": "http://example.com"
}
},
{
"lang": "fr",
"content": {
...
}
}
]
to get all versions in all languages. A big advantage of this solution is that you keep an original structure of the resource (you just nest the original one in multilang resource) - it does not change its structure depending on lang header - that would be messy and inconsistent to get structure x with a language header, and structure y without the header on the same resource.
Other inspirations you may find there.

Permissions to Read Likes via Graph API

Since the REST API has gone, I need to find another way to read the likes for pages of our webapp.
According to the Graph API docs, the following should return the likes for any object (such as a page):
https://graph.facebook.com/v2.6/{PAGE-ID}/likes?summary=true
Oops, An access token is required to request this resource. Turns out, instead of a real token, you can also build an ad-hoc token witht the app ID and secret:
https://graph.facebook.com/v2.6/{PAGE-ID}/likes?summary=true&access_token={ID}|{SECRET}
The above returns a JSON payload, however, it's empty even though I'm trying this with a page having almost 200 likes:
{
"data": [
],
"summary": {
"total_count": 0,
"can_like": false,
"has_liked": false
}
}
Maybe a permissions problem? The app domain and the page URL domain are identical.
Big thanks for any hints to solve this riddle!
It does work with a simple App Access Token too, but i assume you get the wrong idea about that endpoint. There is no way to get the "Page Fans", you can only get "other Pages the current Page likes" with it. Just try this with your App Access Token:
https://graph.facebook.com/bladauhu/likes?access_token=APPID|APPSECRET
It should return the following JSON:
{
"data": [
{
"name": "FKK Scibes Skulls",
"id": "1391253501090151"
},
{
"name": "Dodgeball Austria",
"id": "387249994631552"
},
{
"name": "Turbojugend Scibes",
"id": "105248832848054"
},
{
"name": "HYDRA! Das endgute Satiremagazin.",
"id": "167084486537"
},
{
"name": "VLÜ Hydra",
"id": "113680962002559"
}
],
"paging": {
"cursors": {
"before": "MTM5MTI1MzUwMTA5MDE1MQZDZD",
"after": "MTEzNjgwOTYyMDAyNTU5"
}
}
}
More information about Tokens:
http://www.devils-heaven.com/facebook-access-tokens/
https://developers.facebook.com/docs/facebook-login/access-tokens/
https://developers.facebook.com/docs/apps/changelog#v2_6_changes:
The likes field on the Page node has been renamed to fan_count
As luschn said in their answer, likes are the other pages liked by that page; if you want to get the number of people that like the page itself, you need to request fan_count.

Is it possible to get user detailed using facebook API V2.6

I am using the "taggable_friends" api to get the list of all friends then uses the user ID (a string of 110 chars) to get user detailes like this:
FB.api('/' + gFriend.id , 'GET',{},
function(response) {
console.log("response",response)
});
In the result I get an error
(#803) Some of the aliases you requested do not exist: {The user Id I have submitted}
Did FB blocked user details API in version 2?
taggable_friends if for tagging only, you can´t use it for anything else and you don´t get a User ID. You only get a "tagging token" that can only be used for tagging. If you just want to create a "friend pic collage", you need to use /me/friends instead. Of course you will only get friends who authorized your app with the user_friends permission.
[from comments] I want to show friend pic collage
The taggable_friends endpoint does return URLs of the friend’s profile pictures already.
You get a data structure like this,
{
"data": [
{
"id": "AaKYNqeDaP…",
"name": "Foo Barski",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
{
"id": "AaKBGEbAAvYU…",
"name": "Some One Else",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
So all you need to do is use those URLs provided in the picture structure.

Retrieve comments on Facebook ads through the API

Is it even possible to retrieve comments on Facebook ads through the API (Graph or FQL)? If yes, do I need a whitelisted app to do it? Also, if I have a page access token, is it enough, or I need a user access token with ads_management permission?
Regarding the token usage, a page_token is extended by a given user to a given app. The page_token will have at most the same privileges as the user on his authorized pages and ad_accounts.
Generating a page_token can be done automatically, in behalf of the user, if you already have a user_token with manage_pages permission. Again, this page_token will have at most the same privileges that the user_token you used to generate it.
In other words, having a page_token doesn't amount for any additional privileges than the ones already present in the user_token.
Having said that, you need
a token with access to a given ad_account
that the app for which that token was generated, has that ad_account active in its settings
If the second requisite isn't met, for example for ad_account act_123456789 you'll get the error:
{
"error": {
"message": "(#274) The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API. Account 123456789 not enabled for this application.",
"type": "OAuthException",
"code": 274,
"fbtrace_id": "xxxxx"
}
}
You can try, for example, generating a token with all privileges for the Graph API Explorer App. It will throw the error above because said App doesn't have the ad_account act_123456789 enabled.
So, given you have a token with ads_read extended for an app that has this ad_account listed, and you know the ad_id, you can procede as I explained in thread Get comments from facebook ads (marketing)
Basically, you use the ad_id (for example 123000000) to get the promoted post id and its actions
/123000000?fields=creative.fields(effective_object_story_id),insights.fields(actions)
The answer will contain an effective_object_story_id (for example, let's say it is 456000000_789000000) and its actions broken down by type:
{
"creative": {
"effective_object_story_id": "456000000_789000000",
"id": "123000000"
},
"insights": {
"data": [
{
"actions": [
{
"action_type": "comment",
"value": "12"
},
{
"action_type": "like",
"value": "2"
},
{
"action_type": "post",
"value": "3"
},
{
"action_type": "post_reaction",
"value": "29"
},
{
"action_type": "video_view",
"value": "558"
},
{
"action_type": "page_engagement",
"value": "604"
},
{
"action_type": "post_engagement",
"value": "602"
}
],
"date_start": "2017-08-14",
"date_stop": "2017-08-20"
}
],
"paging": {
"cursors": {
"before": "xxx",
"after": "xxx"
}
}
}
}
If you want to also distinguish paid comments from regular comments, you can query the comments edge of the post_id 456000000_789000000 to get the overall comment count which should be greater than the comments generated by the ad.
You can't pull the actual words of the comment via the API - would make it too easy to scrape.
Yes, Facebook ads that have comments are because the ad is a promoted page post, whether that page post is hidden or not. Page post comments are available via the Facebook API and does not require having Ads API access. Use the graph API endpoint /v2.1/{page-id}/comments to retreive page post comments. See the Facebook Graph API documentation on object comments for more information.

Facebook Insights API is returning no data (empty array) for a post

My application is pulling back a few insights statistics. This works fine for my FB account, which I used to develop the feature, but my users get an empty array, ex:
{
"data": [],
"paging": {...}
}
I obtain authorization via OAuth and I've asked for the read_insights permission. I can verify it has been granted in the list of permissions
https://graph.facebook.com/me/permissions?access_token=XXX
{
"data": [
{
"installed": 1,
"basic_info": 1,
"public_profile": 1,
"read_stream": 1,
"status_update": 1,
"photo_upload": 1,
"video_upload": 1,
"create_note": 1,
"share_item": 1,
"export_stream": 1,
"publish_stream": 1,
"read_insights": 1,
"manage_pages": 1,
"publish_actions": 1,
"user_friends": 1
}
],
"paging": {...}
}
I know the post is valid since I can request it with the graph api
https://graph.facebook.com/[post id]?access_token=XXX
Also, the account meets the > 30 followers requirement for Insights
Update
I can get insights for all posts except those generated by my application. The only difference between posts generated by my app and facebook are:
Facebook has
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"status_type": "shared_story",
Mine has
"privacy": {
"value": ""
},
"status_type": "app_created_story",
"application": {
"name": "Company",
"id": "1111111111111"
},
However I was able to get insights on a Facebook generated status that has privacy:
privacy: {
value: ""
},
So only difference now is "application" and "status_type".
I was using the facebook js sdk to post. If I use server api post I can get insights so looks to me like a Facebook bug
We had a similar problem, we were able to solve it, it's mostly a mismatch of accesses:
just follow the following steps:
Add the user (developer) profile to the company facebook page as an advertiser.
Also, add the same account on the Facebook Bussiness manager as an advertiser.
And then you will receive an email from facebook to confirm the granted accesses. Confirm them , all done.
Now you have all the needed access at the right place.
Lastly, you can test again https://graph.facebook.com/v2.7/XXXXXXXXXXXXXXX/insights/ where XXXXXXXXXXX is the Company Ads' Id