Get current user newsfeed along with post author picture - facebook

I'm trying to obtain all newsfeed posts of the current user along with each post author picture url in a single query, but I cannot succeed.
I can get current user newfeed by calling "/me/home" in Graph Api, and I can get a specific user picture by calling "{user_id}/picture". How can I get every post author picture of my newsfeed in one single query?
Thanks in advance!
Pablo

You can use field expansion to get at this. The one complicating factor is you will have to manually request all the fields you need now. Try this query:
me/home?fields=from.name,from.picture,message,picture

This is pretty easy actually. Use the /me/home query as you have been. But instead of makin a call to /user_id/picture you can just do this in HTML:
<img src="https://graph.facebook.com/{user_id}/picture?type=square" />
E.g.: https://graph.facebook.com/4/picture?type=square

Related

Facebook Group Search post without comments

Hi,
As title, in my facebook group, I need to retrieve only post without comments.
I see the search box and notice that searching something will give an url with
`?query=Word%20Search`
and maybe there is a way to search post without comments by url.
Thanks for help!
You must use the Graph API to retrieve data from Facebook. There is example code how to get the group feed in the docs: https://developers.facebook.com/docs/graph-api/reference/v2.2/group/feed#read
You canĀ“t filter by posts without comments, you need to do the filtering on your own after getting the posts.

How to get all user's likes using facebook's graph API

How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.

Facebook Graph API: Get post/status attached photos

How can one get multiple attachments of a post/status in a group?
For example: A group status that some member wrote and added multiple photos to..
Currently I am using Graph api to get the group stream with group_id/feed and unable to see images attached to a single status - while accessing the feed from Facebook itself I can validate that there are few photos attached to the status.
Using FQL it is possible to get the attachments with the following query:
SELECT attachment FROM stream WHERE post_id = each_post_id
Considering I will have to send this request per post and that FQL will soon be gone I am searching for an alternative.
I was looking for a solution for this as well and actually just found it.
The Facebook Platform changelog says the following:
/v2.1/{post-id} will now return all photos attached to the post: In
previous versions of the API only the first photo was returned with a
post. This removes the need to use FQL to get all a post's photos.
With this knowledge I went to the Graph Api Explorer and found a post that had 2 attachments or more added to it.
After finding the post, and with that the post id, I tried the request Facebook told me to do:
/v2.1/{post_id}
This does NOT give you the desired result. The nice thing about the explorer is that you can search for fields you want to add to your request.
You want to add the attachments (plural) field. NOTE: It might be that the graph api explorer only shows the attachment (singular) field. This is NOT right.
So, to summarize:
Get the post id of the post containing the images.
Create a new request to the graph api that looks something like: /v2.1/{post_id}?fields=attachments
Then read the result to get your desired attachments.
I hope this helps you out as I have been struggling for a while as well.
KR
PS: This is tested with a user and not a group, but it should be basically the same.
PS2: This is just an explanation of how you get attachments of a single post. You can also add the attachments field to the /me/home egde to immediately get all attachments at every post like so:
me/home?fields=message,from,attachments
PS3: The permissions you need are
user_status
read_stream
user_photos
user_videos
Facebook is not very clear on this matter and it is very hard to figure things out like this. So I hope this will help everyone that is searching for this solution.
I answered for the same question here : /v2.1/{post-id} does not deliver photos
It seems it's a Facebook bug. My colleague opened an issue. Here's the link: https://developers.facebook.com/bugs/762280800482269/
You also can find some info here:
https://developers.facebook.com/bugs/790976317600139/
Hope it will help you.

facebook batch request to get all the photos

I want to get all the photos of the user who gave permission to the app. Currently, I tried single and batch request of Graph API but it always paginates the results. Is there a seamless way to get all the objects without following pages?
ps: I'm using PHP-SDK so answering in php is the money :)
I found out that giving limit=0 is solving the problem. It still generates paging object but they return empty data set. So, limit=0 returns the whole dataset in one shot.

Facebook: Get all "Likes" for a specific page

I am currently planning a facebook integration on our website. In the example given at the Getting Started page (http://developers.facebook.com/docs/opengraph), you can see that I like "The Rock" on Imdb. If I were Imdb, would it be possible to query the user object to get all likes on Imdb? For example would it be possible for them to build a page like "these are the films where you clicked the like button on our website"?
Thank you for your answer!
To get the likes for a page you need to do this:
use http://graph.facebook.com/
this will return a JSON object be default. Just snatch the likes property off it.
http://graph.facebook.com/wearex3 for example
But what you are asking requires you to request access to the user's data and from there get all the likes.
http://developers.facebook.com/docs/opengraph and http://developers.facebook.com/docs/guides/web are what you want to read.