facebook get shared count not-deleted and not-private - facebook-fql

Is possible to get share count from url exclude "deleted shared post" and private post
"SELECT share_count FROM link_stat WHERE url = A" return all shared action
https://api.facebook.com/restserver.php?method=links.getStats&urls=http://example.com/&format=json same data

Temporary is not possible
Stephen Doyle: What you've described is the intended operation of that endpoint at present - the number includes all shares regardless
of whether those shares are currently visible to the user making the
API call
details: https://developers.facebook.com/x/bugs/1429537640626458/

Related

Facebook Api search users by name returning empty data

I used this url with access token https://graph.facebook.com/search?q=Marcus&type=user&access_token= and it returns empty data data []
Settings https://i.imgur.com/6hEiO5y.png
I was trying to get a list of users with their name using javascript. Is it possible ?
as mentioned in the comments here is the official Facebook note, that you cannot search for type = user anymore:
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
The /search endpoint for pages, videos, groups and events has been disabled by facebook after the cambridge analytica scandal.
Faceboook Changelog:
You can no longer use the /search endpoint with the following object types:
event
group
page
user

Facebook graph API {post-id}/likes returns empty data

This request returns an empty array: graph.facebook.com/773227196065108/likes, but this request returns a normal array: graph.facebook.com/576234822476425/likes.
First post - post from user, second post - post from page.
How do I get a normal result in the first case?
http://graph.facebook.com/773227196065108 returns
{
error: {
message: "An access token is required to request this resource.",
type: "OAuthException",
code: 104
}
}
since its a user post and probably not public, you will have to access it using a proper access token on behalf of the user . also the number of likes obtained via graph api is dependant on the the privacy settings of people who liked the post .
the second post is one from a page and is public, so its directly accessible for you .
773227196065108 is a user whereas 576234822476425 is a page. Public page posts can be inspected in the API, public user posts have certain restrictions applied to them such as, the queried user must be using the application as well. If the queried user isn't using the querying application the response will be empty.
In addition /me/likes/773227196065108 will not work as /me/likes are only for pages not posts.

How to get "news main stream" from the main facebook site?

How to get the general information listed on the home page?
Facebook makes a request to
https://www.facebook.com/ajax/pagelet/generic.php/LitestandMoreStoriesPagelet?
with params:
ajaxpipe
ajaxpipe_token
no_script_path
data
__user
__a 1
__dyn
__req
__rev
__adt
And although it returns a json (inside a script with conditions...) is not a clean answer.
Is there another way to get that data? I do not want to use the sdk.
If you want the 'News feed', you'll want to use the /user/home/ API endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.1/user/home
e.g. https://graph.facebook.com/me/home?access_token=VALID_ACCESS_TOKEN will just grab your own News Feed.
You can also filter by any of the 'filter_key' values returned from the FQL query (use the Graph API Explorer and API version 2.0):
SELECT filter_key, name, type, value FROM stream_filter WHERE uid = me()
e.g. adding the query string filter=app_2305272732 will return a feed of things from the 'Photos' app (i.e. photos added to Facebook by your friends)

How to filter user's news feed to posts/actions from a specific app in Graph API

I have a Facebook app and I want to filter user's news feed to get latest posts/actions that was posted using my app, in Graph API.
I've found this: How to get activity from my app with Facebook Graph API?
This one is okay for getting actions/posts by a specific friend (or the user itself), what I need is almost the same, with the difference that I need this "stream" by all friends of the user that use my app, not a single user.
Then I've found this: Facebook graph api : how to filter app feeds. For this one, the example in the question itself returns empty data for me (with the appropriate access token with read_stream permission). The only answer suggests to use FQL. I've tried SELECT post_id, message, comments, likes FROM stream WHERE app_id = MY_APP_ID and I got this error:
{
"error": {
"message": "Your statement is not indexable. The WHERE clause must contain an
indexable column. Such columns are marked with * in the tables linked from
http://developers.facebook.com/docs/reference/fql ",
"type": "NoIndexFunctionException",
"code": 604
}
}
How do I retrieve the list of all the last (say 100) posts from a specific app by the user and their friends, from the user's scope?
With all FQL queries, your WHERE clause must include at least one indexable field (those are marked with a star next to the field name in the docs) – for performance reasons.
So for the stream table you have a choice between source_id (id of the user whose wall the post is on) or filter_key. You can read the valid filter keys from the stream_filter table – but every user has the filter key nf for what shows up in their news feed. (post_id is also indexable, but of no use for us here.)
So you could try filtering with WHERE filter_key = 'nf' AND app_id = 'YOUR_APP_ID' – that should give you the posts that your active user is able to see in their feed that where made via your app.
You could also try with source_id, filtering that to either being equal to me() (your current user in FQL), or it being in the list of your friends (whose ids you can get from the friend table, again using me(), as a sub-query) - so like this,
… WHERE (source_id = me() OR source_id IN (SELECT uid1 FROM friend WHERE uid2 = me())) AND app_id = 'YOUR_APP_ID'
– but I think that will have less good performance, so I’d try with filter key first and see if that gets you the posts you want.
EDIT: So, as the questioner found out, using /me/home?filter=app_MY_APP_ID works apparently better, and is also easier. Whoever else might need this, they should use this version, since it is more reliable – FQL often gives less results then one would expect.

Retrieve Facebook users that like a URL / web page via Open Graph

Is there a way to retrieve the list of Facebook users that have clicked the like button on an external website?
E.g. there is a domain example.com which has been confirmed via Facebook Insights to belong to fbUser1 (using OG meta tags).
Somewhere on example.com there is a page with multiple XFBL like buttons, each one pointing to a further specific URL on example.com, e.g. example.com/xyz, example.com/abc etc.
What I'd like to get is the list of users that liked example.com/xyz and of those who liked example.com/abc.
My intuitive approach would be to look at graph.facebook.com/123456789/likes (where the number is the ID of the domain taken from FB insights), but this always returns an empty dataset:
{
"data": [
]
}
I've also tried getting an OAuth access token from https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APPID&client_secret=APPSECRET (where APPID and APPSECRET are taken from a FB application that is marked as owning the domain using OG meta tags), but that makes no difference.
I'd also be interested in a non-OpenGraph (i.e. JS SDK, FQL etc.) solution.
EDIT: Using the following code (according to WideBlade's answer below) still gives me an empty list of likes (the second query never returns):
var objectsQuery = "select id from object_url where url in ('http://example.com/xyz', 'http://example.com/abc', 'http://example.com/123')";
var likesQuery = "select object_id from like where object_id = {0}";
FB.Data.query(objectsQuery).wait(function (objectRows) {
console.log(objectRows);
FB.Array.forEach(objectRows, function (objectRow) {
FB.Data.query(likesQuery, objectRow.object_id).wait(function (likeRows) {
console.log(likeRows);
})
});
});
FQL Should do the trick.
$facebook->api_client->fql_query('SELECT user_id FROM like WHERE object_id="OBJECTID"');
Here is the link.
Some general info about FQL.
FQL is initiated using the JavaScript SDK, in this way.
If you can post some sample code-I can try and give some more specific help.
A note should be made-once you've got the user ID's, you can just query the names and get them in a list.
EDIT: To get the URL of an object you should query this table using fql.
This cannot be done. Facebook does not allow you to query for specific user ID's of people who have liked a certain page. This is because of privacy concerns.
See the disclaimer on this page https://developers.facebook.com/docs/reference/fql/like/