Get only photos from users wall feed using facebook graph api - php

https://graph.facebook.com/me/home?access_token=token
will return all feeds for a user news feed. But i am looking for filters like type=post or type=photos etc
Is this functionality available in facebook api??

You can filter results in home connection of user filtered by user's stream filters by using filter argument. For example photos may be accessed with:
https://graph.facebook.com/me/home?filter=app_2305272732
And Links:
https://graph.facebook.com/me/home?filter=app_2309869772
filter should be one of those returned by next FQL query:
SELECT filter_key FROM stream_filter WHERE uid=me()
See stream_filter table for details.
BTW: Beware, not everything may be possible to use as filters, for example statuses (those easier to access via /me/statuses than via /me/home)...

I couldn't find it documented, but I just tried the following url and it worked:
https://graph.facebook.com/me/home/photos?access_token=token

For anyone looking to do this with fql, I recently wrote a blog post of getting photos and videos from Facebook news feed. And here is the query that I use.
SELECT actor_id, created_time, likes, post_id, attachment FROM stream WHERE filter_key IN ( SELECT filter_key FROM stream_filter WHERE uid = me() AND (name = "Photos" OR name = "Video"))

Related

FB Graph Api Search, convert FQL query to fetch nearby pages?

I've used the old Facebook SDK where I could do FQL-queries. I want to fetch all nearby places that also has a page attached. And with those results, I want as many columns as possible.
I want to rewrite this function so I can do the same but with the latest Facebook SDK 2.3.
The old way:
SELECT name, type, page_id, hours, categories, about, bio, description, general_info, location, checkins, fan_count, phone, pic_big, website FROM page WHERE page_id IN(SELECT page_id FROM place WHERE distance(latitude, longitude, '37.76', '-122.427') < 1000)
But this doesnt work so well with the new SDK. I've tried the search-method and tried to write different types of queries (in the 'q' parameter) but nothing gets close to this.
As you can see, I want as many columns about the pages as possible.
The closest I've come is this far: https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=search%3Fq%3Dcoffee%26type%3Dpage%26center%3D37.76%2C-122.427%26distance%3D1000&
Does anyone know how I should think/do in order to get this data in the new way?
Have a look at
https://developers.facebook.com/docs/graph-api/reference/page#Reading
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#fields
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#search
You can specify the desired result fields according to the fields which are available for the respective object.
For example
/search?q=coffee&type=place&center=37.76,-122.427&distance=1000&fields=id,name,hours,category,category_list,about,bio,description,general_info,location,talking_about_count,were_here_count,likes,phone,cover,website
Try it
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=search%3Fq%3Dcoffee%26type%3Dplace%26center%3D37.76%2C-122.427%26distance%3D1000%26fields%3Did%2Cname%2Chours%2Ccategory%2Ccategory_list%2Cabout%2Cbio%2Cdescription%2Cgeneral_info%2Clocation%2Ctalking_about_count%2Cwere_here_count%2Clikes%2Cphone%2Ccover%2Cwebsite
Keep in mind that the fieldnames are not the same from FQl to Graph API.

Facebook - get user likes and comments

Is it possible to get the user likes and comments from facebook?
With the graph api, you can can do me/likes, but that only returns the pages you liked, and I want all the likes. So also the url's, posts, pictures, ... I liked. The same for the comments.
Or is there a query to get the activity log from an user?
You can use the
FQL like table (https://developers.facebook.com/docs/reference/fql/like/)
FQL comment table (https://developers.facebook.com/docs/reference/fql/comment/)
to query for object comments and likes. Then, if you want to distinguish between object types (photo, album, event, group, note, link, video, application, status, check-in, review, comment, post) for getting more info about the like or comment, you need to do queries like this for each object type:
select src, link from photo where object_id in (select object_id from like where user_id=me() and object_type="photo" limit 25)
For URL likes you can use
FQL url_like table https://developers.facebook.com/docs/reference/fql/url_like/
You can use the Graph API. You have to fetch them with different end-points, like:
Get the posts with: /me/feed - demo
Perms req: read_stream
Get the photos with: /me/photo - demo
Perms req: user_photos
Now, to get the likes use this:
/likes?id={post_id|photo_id|url}
for comments:
/comments?id={post_id|photo_id|url}
You can test your calls in Graph API Explorer

Feed data between 2 persons on Facebook

Is it possible to get the data posted by a person on the timeline of one other person on Facebook?
If it is, how could I do it? Do I need to use FQL queries?
This will get you things that someone else has posted on the active user's timeline with FQL:
SELECT actor_id, created_time, message, attachment FROM stream
WHERE source_id=me() AND actor_id != me()

Facebook open graph, filtering friends list array

I want my application to filter the friends list I get using the open graph. People who login into my site must see only their friends who also use my app. I've noticed this on many applications like Quora, Thumb etc. How can it be done using php?
Can easily be done when you use FQL to query the user table (in conjunction with the friend table) – that has a field is_app_user, so a query like
SELECT uid, name FROM user
WHERE uid IN (SELECT uid1 FROM friend WHERE uid2 = me())
AND is_app_user
will return only those friends of the current user that are also users of your app.
You can access the lists of a user by access the friendslist connection via graph api
example: http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Ffriendlists
/me/friendlists?access_token='.$access_token.'

Facebook API FQL multiquery to get actor name as well as ID

I am making an FQL query using the Facebook PHP API, like so:
$stream = $this->facebook->api('fql', array(
"q" => "SELECT post_id, actor_id, message, description, description_tags, type, attachment
FROM stream
WHERE filter_key in (
SELECT filter_key
FROM stream_filter
WHERE uid=me() AND type='newsfeed'
) AND is_hidden = 0"
));
This gives me the user's news feed. However, this will only provide me with the ID of the actor - I need the actor's name. (By actor, I mean the author of the story in the news feed.)
I understand that I will need to query the API again to retrieve the name. How do I perform such a multiquery? Using this example, how can I get the actor name?
Most people's initial reaction would be to suggest a multi-query. However I dont suggest it for the following reason: It is possible you app can already knows the name of the actor.
Let's say you do lots of these calls to get stream items (one of my production applications does and I've got it coded the way I describe). What you don't want to do is overload the API and make Facebook unhappy with your app id and start reducing your call limits!!
So, what you can do is cache (using memcached, web application cache, database, or other) the user name (as the name to id rarely changes for a give id) based upon the actor_id. This is also valuable to find the to/from ids for other facebook fql objects like comments, likes, etc.

Categories