facebook, how to get many user's profiles details by id's array - facebook

How i can get users details in FB by their id?
I have ids array, and i need to get all user's profiles by one query from ActionScript, is it possible?

This example is taken from the very first page of the Graph API Documentation under the 'selection' heading:
You can also request multiple objects in a single query using the
"ids" query parameter. For example, the URL
https://graph.facebook.com?ids=arjun,vernal returns both profiles in
the same response.
This works with the ?fields selector too, so you could also do https://www.graph.facebook.com/?fields=id,name,picture&ids=<CSV LIST OF IDS>

Related

Facebook API 2.8: Getting Members of a FriendList object

I am trying to list all friends who use my app and belong to a FriendList object. The FriendList object could be, for example, 'Close Friends', or 'Family'. I understand that I can get a full list of friends who use my App using the /me/friends endpoint, but that's not what I am looking for. I need only those who belong to a given FriendList.
When I GET /{{friend-list-id}}/?metadata=1 the metadata shows a 'connections' object with a 'members' property. The value of the members property is:
https://graph.facebook.com/{{friend-list-id}}/members
When I hit this URL (and include my access token), I get a FacebookResponseException with the message '(#12) Unavailable in this version'. I am using API v2.8.
Is it really the case that I can't get the contents of the FriendList? (Remember that I am only needing those that use my app).
Alternatively, is there a way that I can filter the /me/friends response so that it includes only those who are on a given FriendList?

How to get Facebook page total likes number with the new Graph API (v2.4)

So recently there was a update to the Facebook Graph API and now pretty much everything requires a access_token to retrieve any type of data.
Previously you could get the number of page likes by accessing the graph like so:
http://graph.facebook.com/{page-name}
But now if you try it says you need to have a access token because of a recent update to the API. Now the issue i am having is i cant access the likes even with an access token this is the response i am getting:
Request
http://graph.facebook.com/{page-name}/?access_token={access_token}
Response
array(2) {
["name"] "Page Name"
["id"] "Page Id"
}
Now at first i thought the access token wasn't being generated with the correct scopes but i am 99% sure you only need read_stream to pull that type of data.
Second thought is that they have removed the ability to acces likes of any page and you need a page token to receive that type of data or finally i am missing something incredibly small here and its still achievable?
So my question is can you still get the number of likes of any page using the Facebook Graph API and if the answer is yes how do you do it?
any help appreciated
This can help you! Just add ?fields=likes after the page name/id. You can use any access token for fetching data!
graph.facebook.com/{page_name}?fields=likes&access_token={token}
The Graph API v2.4 reduces the number of fields in default responses.
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance: To help improve performance on mobile network connections, we've reduced the number of fields that the API returns by default. You should now use the ?fields=field1,field2 syntax to declare all the fields you want the API to return.
If you do ?fields=likes it should show up.
You can do like this:
https://graph.facebook.com/v2.4/{page_id}/fields=likes

Facebook Marketing API some field are not shown

I have a development level access to Marketing API and it looks like I cannot read some fields of specific objects.
For example I try the following call:
You can see that promoted_object, link_url and object_url are not displayed in the result. And I should have one of those three value as the Ads was ad to promote "web site click".
Is it a bug or a limitation of the development acces or I am doing something wrong?
It is true that not all fields are readable by all apps, however in the case above it is most likely that these fields are empty on that object and therefore not returned in the response.
Promoted object, for example, is required on the adset level now, however it may be the case the adset you are trying to read is very old and therefore does not have one specified.
In regards to the creative fields, again not all creatives have these fields and in the case they are empty, are not returned in the response. You should check the promoted_story_id to see if this contains what you're looking for.

Facebook Graph API: Find graph object from post URL

Given the URL of a public Facebook post, how can one find the post object in the FB Graph API? (secondarily, why are so many user feeds empty or nearly empty when accessed through the API?)
We would like to be able to comment on or like a post via the v2.x
Graph API, given the post's URL. Doing so requires the post's object
ID, which we can make some educated guesses about, but accessing
the actual object through the API has proven unreliable (works for some posts but
not others).
v2 of the API introduced app-scoped user IDs, and post IDs generally seem
to be of the form {app-scoped user id}_{unique post id}. Here are the
details of some attempts to find posts in the API with various combinations of
these IDs (global user id, app-scoped user id, and post id).
Starting with a simple example: https://www.facebook.com/evan.prodromou/posts/10153023417510505. Key characteristics are that it's public, it's not a share of another post, and most importantly it has no photo(s), which add extra ids and URLs for the individual photo(s) and photo set. Evan's profile is also public, i.e. https://www.facebook.com/evan.prodromou doesn't show the generic This content is currently unavailable
Trying the bare post id from that URL, /v1.0/10153023417510505 and /v2.2/10153023417510505 both give the Unsupported get request (code 100) error.
Evan's global user id is 525575504. Attaching that as a prefix, /v1.0/525575504_10153023417510505 and /v2.2/525575504_10153023417510505 still both give the same Unsupported get request error.
Same error using his app-scoped user id instead, /v2.2/10152350676805505_10153023417510505.
OK let's try the other direction. We'll page through the user's feed until we find the post in question. It feels like this is more the expected use case for the API...
Both the global /v2.2/525575504/posts and app-scoped /v2.2/10152350676805505/posts return nothing, but /v1.0/525575504/posts returns two recent posts, this like and this post. Not sure why only those two, even though has plenty of other recent public posts. The like is fetchable via its id field in both api versions, i.e. /v1.0/525575504_10153045879215505 and /v2.2/10152350676805505_10153045879215505, but both API versions return the Unsupported get request error when fetching the post via its id field, e.g. /v1.0/525575504_351575675029953 and /v2.2/10152350676805505_351575675029953
Trying another public post, this one with pictures: https://www.facebook.com/andigalpern/posts/678121182314631 . /v1.0/100003502653187_678121182314631, /v2.2/100003502653187_678121182314631, and /v2.2/499657186827699_678121182314631 all error.
/v1.0/100003502653187/posts only includes one post, a like, and /v2.2/100003502653187/posts is empty.
For reference, here is the GitHub issue where we have been tracking this problem.
Basically you would need read_stream for this (which your app will not get granted). And yes, even though the post is public, you still need read_stream to be able to get read access to all kinds of posts.
You can easily play around with this in Graph API Explorer. First give your app read_stream permission to get ids of items in your feed – that will give you ids of the “form app-scoped user id underscore post id”. Then remove read_stream (by clicking “Get Access Token” again and using the “Clear” button), and try several of the user_* permissions – and you will see that for most of your posts, even the public ones, you will still only get “Unsupported get request”, which just means you are not allowed to read that object.
F.e., I have a public post where shared a video post from another page on my timeline, the type is video and status_type is shared_story, but neither user_status nor user_videos allow me to read this post – only when I grant read_stream again, my app can read that post. Same with another public post of type status and status_type mobile_status_update – readable with read_stream, not with any of the user_* permissions.
In short: What you want to achieve is not possible any more with API v2 and the restriction that read_stream will only be granted to apps on platforms where no official FB client exists.
A one proposition is to make api calls to write facebook posts since those return valid post_id that you could use
Second,
When you try https://developers.facebook.com/tools/explorer/256884317673197/?method=GET&path=525575504%2Fposts&version=v2.0&
You can see that his posts ID's are not starting with his public id as you wrote 525575504_*
but they still put unsupported get request
https://developers.facebook.com/tools/explorer/256884317673197/?method=GET&path=10152853212485505_351575675029953&version=v2.0
Third since above doesnt work are those posts public for sure?

Convert any facebook URL into a graph ID

Is there a simple, reliable and potentially future-proof way to extract a graph ID from the API given any facebook URL? By "any facebook URL" I mean the URL for a personal profile, page, group, etc. All these things have various formats so I imagine there must be something in the graph API to definitively convert a facebook URL into an ID, right?
No, there isn't a way to do this simply within the API. You will need a set of pattern matching to match the various types of urls to extract either the id (album,note,photo,status) or username.
For example
Photos
facebook.com/photo.php?fbid=10100213582161431&set=p.10100213582161431&type=1&theater
https://graph.facebook.com/10100213582161431
Posts
facebook.com/zuck/posts/10100210345757211
https://graph.facebook.com/10100210345757211
Pages
facebook.com/pages/Joel-Spolsky/106083232757300
graph.facebook.com/106083232757300
Videos
facebook.com/video/video.php?v=10150398154330484
graph.facebook.com/0150398154330484
Events
facebook.com/events/138745136241434/
etc ...
Then it gets further complicated that even if you were able to get a silver bullet function that handles all these links your app would need to grant access to numerous permissions in order to access certain objects.
You may be able to get away with most links that have the id at the end but not all. So you can maybe use a regular expression catching links that end in numeric characters.
There is! You are looking for the object_url table, which you can query using FQL or directly with a request. See here: http://developers.facebook.com/docs/reference/fql/object_url/
EDIT:
You can also do this, but obviously less optimal:
function getObjectByUrl(url, cb) {
FB.api("/" + url.replace(/^.*?www.facebook.com/, ""), cb);
}