How to get all counts of likes of post of our page? #LinkedIn - linkedin-api

How to get all counts of likes of post of our page, Actually we have created a Page and posted some articles. Now I want to retrieve all likes of my post using APIs, I can get the access token from Postman.
When i am run the V2 API to get data thru poastman, i got the following error:
"Not enough permissions to access: GET /socialActions/".
Please advise what more permission required.
Get the Access Token from postman for OAuth2.0 under Auth navigation of postman. After getting the access token, run the https://api.linkedin.com/v2/socialActions/{activity}
I am getting following error
{
"serviceErrorCode": 65604,
"message": "Empty oauth2 access token",
"status": 401
}
I used in other system Postman then found following error:
{
"serviceErrorCode": ,
"message": "Not enough permissions to access: GET /socialActions/",
"status": 401
}
Should be come the result data in JSON format

You can also use this request https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/share-statistics#sample-request
Following is sample request
https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:xxxxxx&shares=urn:li:share:xxxxxxxxx&count=1000
Sample Response :
{
"elements": [
{
"totalShareStatistics": {
"shareCount": 2,
"clickCount": 1,
"engagement": 10,
"likeCount": 5,
"impressionCount": 7,
"commentCount": 5
},
"share": "urn:li:share:xxxxxx",
"organizationalEntity": "urn:li:organization:xxxxx"
}
],
"paging": {
"count": 1000,
"start": 0,
"links": []
}
}

Related

FB Graph API Response Paging Next contains access_token

Now I am working with Graph API 3.2.
Is there any opportunities to configure within my request went to Graph API to not get back the access token in the end of the response param, called Paging Next?
i.e: here is the documentation.
I just don't want to get back the access token as a plain text in the repsonse, like here:
"feed": {
"data": [
{
"created_time": "2017-12-12T01:24:21+0000",
"message": "This picture of my grandson with Santa",
"id": "{your-user-id}_1809387339093972" // Post ID
},
{
"created_time": "2017-12-11T23:40:17+0000",
"message": ":)",
"id": "{your-user-id}_1809316002434439" // Post ID
},
{
"created_time": "2017-12-11T23:31:38+0000",
"message": "Thought you might enjoy this.",
"id": "{your-user-id}_1809310929101613" // Post ID
}
],
"paging": {
"previous": "https://graph.facebook.com/v3.2/{your-user-id}/feed?format=json&limit=3&since=1542820440&access_token={your-user-access-token}&__paging_token=enc_AdCgj6RSGWTYV7EXj2cFlOWJjbZCq8oI3ogIpLrxPCVK3U8Kad0EgsZA2vri3YKIwl71XGRDJz9C8TgqMeyiu8U5CD&__previous=1",
"next": "https://graph.facebook.com/v3.2/{your-user-id}/feed?format=json&limit=3&access_token={your-user-access-token}&until=1542583212&__paging_token=enc_AdDLmzUgWiLo6oHGCI53S5begiKOfNZBY0affrLMWgheBzfwMA7XSKmgjyNbuZBIptdXc18j1Se0Dm7vEsePh1SoM3"
}
},
"id": "{your-user-id}"
}
Thanks anyway!! :)
It is answered elsewhere: https://stackoverflow.com/a/29900228 but it is good to have a reference to that answer here, too.
The solution that worked for me with various Graph API versions is to pass the token in the Authorization header:
return requests.get(url,
headers={'Authorization': 'Bearer ' + token})
If the token travels in the header, it won't appear in the response anywhere.

Get facebook fans count using API 2.8

How to get Facebook fans count using http request in API 2.8
-- I test these requests but not working
This return an array but no Fans Count
https://graph.facebook.com/v2.8/{APP_ID}?access_token={ACCESS_TOKEN}&edges=fan_count
Return
{
"category": "Entertainment",
"link": {APP LINK},
"name": {NAME},
"id": {ID}
}
-- This throw an error array
https://graph.facebook.com/v2.8/{APP_ID}?access_token={ACCESS_TOKEN}&fields=likes
Return
{
"error": {
"message": "(#100) Tried accessing nonexisting field (likes) on node type (Application)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "FlkGoTOJ403"
}
}
This is the correct one:
https://graph.facebook.com/v2.8/{PAGE_ID}?access_token={ACCESS_TOKEN}&fields=fan_count
Not sure why you would use an App for this, Fans are for Pages.
Use {PAGE_NAME} instead of {APP_ID}
GET ACCESS TOKEN: https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET_KEY}&grant_type=client_credentials
GET FANS COUNT: https://graph.facebook.com/v2.8/{PAGE_NAME}?access_token={ACCESS_TOKEN}&fields=fan_count
Thanks for luschn

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.

Facebook Graph API does not return full post data

I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.

how to get facebook post after a graph search?

https://graph.facebook.com/search?access_token=xxxxxx&q=hello&type=post&fields=from,message,picture,link,name,caption,description,created_time&limit=1&locale=en_US&scope=publish_stream,offline_access,user_status,read_stream
After such a graph search, I get some data like:
{
"data": [
{
"from": {
"name": "Eric Fluegge",
"id": "100000626293694"
},
"message": "Well, here's go nothing. Hello Tennessee.",
"created_time": "2013-03-30T19:23:44+0000",
"id": "100000626293694_567340783296793"
}
],
"paging": {
"previous": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&since=1364671424&__previous=1",
"next": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&until=1364671423"
}
}
so, is "id": "100000626293694_567340783296793" a post id? If so, how to use this post id, query again, get only this certain post information? I would like to store post id to mysql table, then I want to query the post anytime in the future, thanks.
EIDT: in app setting, i have set the publish_stream,offline_access,user_status,read_stream
EIDT2:
I have tried into Graph API Explorer, choose read_stream and generate a long live token.
SELECT post_id, actor_id, message, type, attachment FROM stream WHERE post_id = "100000626293694_567340783296793"
the result still empty. so I cannot get a post bcause i am not a friend of the post auther? or 100000626293694_567340783296793 is not a post id? or other reason?
Yep, the "id": "100000626293694_567340783296793" is a post ID, you can query its data again with the following URL: http://graph.facebook.com/100000626293694_567340783296793
Attention!
You should ask for the read_stream permission/scope too! Or else you'll get the following error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
And of course, append the access_token to your GET url. (and don't forget https too)
You can check the Graph API Reference here: Post - Facebook Developer Reference