i am starting on a php based facebook app.
the documentation at facebooks developer page is quite confusing.
i have chosen the iframe method for rendering the canvas page. i have made my app in php and is hosted on my server. now the app loads fine in apps.facebook.com canvas. but the thing is I am unable to make API calls work.
what i wanted to know is how to transform the xml/JSON data received from the api calls to valid user-readable data. i mean friends.get gives me a bunch of uids. now how to make them appear as valid user profile image thumbnails or links?
i am very new to this. so any help would be appreciated. i just need to know how to work with the facebook API.
I would suggest using FQL instead - building your FQL queries will help you understand much more what goes on in FB under the hood as well plus if you are good in SQL you can combine multiple queries to give you friends pics and their IDs from diff tables in one resultset...
Use the FB fqlquery function call and pass your required column names there - e.g. you can see your stream from the following table: http://wiki.developers.facebook.com/index.php/Stream_%28FQL%29 and you can issue queries according to the examples given here: http://wiki.developers.facebook.com/index.php/Fql.query
e.g. this gives me the newsfeed from stream table, for all my friends (only):
$logged_in_user = $facebook->get_loggedin_user();
select source_id, post_id, message, likes, created_time, updated_time from stream where source_id in (select uid from user where uid in (select uid2 from friend where uid1=' . $logged_in_user . ')) and filter_key=\'nf\' order by updated_time"
You can query the User FQL table for the picture URLs of your friends and display those URLs in image containers of the frontend lang of your choice: http://wiki.developers.facebook.com/index.php/User_(FQL)
Use the Console for testing your queries: http://developers.facebook.com/tools.php
And use the MultiQuery http://wiki.developers.facebook.com/index.php/Fql.multiquery later when you are more comfortable using FQL queries
Related
I need get ME posts in one of my manage pages, with the new version of facebook sdk.
Example:
I'm manage on Page A, and add a post in my name Adexe Rivera, and in this page there are a lot of posts. So I want to filter only posts by Adexe Rivera.
I know for get posts on pages it's necesary /page/feed, but I need add the filter from user.
I tried with Graph Api Explorer, with this FQL:
SELECT source_id, actor_id, post_id, target_id, message FROM stream WHERE source_id = "PAGE_ID" AND actor_id = "MY_ID"
and get the information that I'm searching.
But I know that since v2.0 FQL not works for sdk, so that I need it's make the same like FQL works in this version of graph
I already tried what documentation said, but not get my posts.
A user access token is required to retrieve posts visible to that person.
Thanks in advance
Filtering is not possible, you can only use the existing endpoints and filter on your own after getting the entries. There are several different endpoints, make sure you are using the correct one. They are all documented very well: https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed
Also, an App Access Token should be enough to get access to the endpoints if it´s a public post on a non-restricted Page:
An access token is required to view publicly shared posts.
If you don´t know about Access Tokens, read those articles:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
Finally, it is not possible to use FQL giving me the expected result, so getting the "from" field in the /PAGEID/feed endpoint, and filtering the results, I get what I wanted.
Thanks for your answers and for their penalties, I have spent several days trying to maximize the performance of the SDK facebook.
Cheers
In my canvas app I've specified that I want to recieve all photos available to me (taken by me or shared with me) which have both "friend1" and myself tagged. I have permissions for user_photos and friends_photos.
My FQL query is as follows:
SELECT object_id FROM photo WHERE(object_id IN (SELECT object_id
FROM photo_tag WHERE subject="friendID"))AND(object_id
IN (SELECT object_id FROM photo_tag WHERE subject="myID"))
What I'm seeing: I am indeed consistently receiving a set of 3 photos which have both me and friend1 tagged, but not all of them! I know there are more photos (12 in total) which have the both of us tagged because I can access them through the normal facebook "see friendship" page. The only pattern I'm seeing is that the owners of the received photos are not in the set of owners of the 9 photos I'm not receiving. In other words, I'm getting all photos from some friends, and no photos from other friends. All 12 photos are shared with me.
My result does not have any paging tags, so this is all the information returned.
The result is exactly the same in the API explorer and in practice.
What I want to see: all the photos with me and friend1 tagged.
Concerns:Is there a problem with my query, from a syntax point of view? Can photos "shared with me" not be accessible with permission:"friends_photos" in some special cases?Or is there another aspect of the FQL tables that I'm not addressing - should I look at other tables like "album"?Could this be an issue with my access token - I assume since I'm getting anything at all that my authorization is good?
I know I've asked about 5 questions here, but any help at all would be greatly appreciated, and please let me know if I should include any more information.
Many thanks!
The photos are probably not accessible through the API. If the owner has restricted the photo's visibility, or the photo's owner has blocked app access to their data, Facebook will not return this information via the API.
Assuming you know the third party who took the photos, you can take a look to see the publicity level of the post, and also ask them if they've blocked apps.
Keep in mind, that when working with the Facebook API, you'll never get ALL of anything. You'll take what Facebook gives you and be happy about it.
You won't get paging links in FQL. You will only see those in Graph API queries.
I have this project I'm working on (php mysql), it contains blocks of movies that can be shared through facebook like. The thing is that I want to count the facebook likes into DATABASE (which is movies table and users favourite table).
Have you looked through the facebook developer docs? Using the javascript api you can use methods such as "edge.subscribe" to call a function when people click like. This would then allow you to make an ajax request. The first part of this document describes this scenario
https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
I'd like to fetch statuses from users facebook newsfeed via the graph API.
It seems to be pretty simple when I have the right access token, then I can fetch this data with http://graph.facebook.com/home... But I want to fetch only statuses; no links, photos, videos and so on..
On the documentation page, I've seen many possibilities to specify selected data, for example I can limit obtained count of posts. Is there any possibility to control which data will be particularly fetched and which not? For example like graph.facebook.com/home?type="status"..
I can classify it in my PHP script, but then I need to be able to fetch a few more posts, like when I click on the more button on facebook or twitter, etc..I see some pagination data in Facebook JSON(I hope it's JSON:)), but I am propably not capable to use it in right way..
Thanks for your help!!
The doc page http://developers.facebook.com/docs/api says:
The Graph API allows you to read properties and connections of the Facebook social graph. You can use the API to read specific fields, get pictures of any object, introspect an object for metadata and get real-time updates on any changes.
...and...
You can choose the fields (or connections) you want returned with the "fields" query parameter. For example, this URL will only return the id, name, and picture of Ben: https://graph.facebook.com/bgolub?fields=id,name,picture
I'm used to working with Twitter, where friend/follower totals are available in a simple XML request.
My goal is a simple "enter your username/user id, and display your friends count".
Is there something like this for Facebook? From what I gather, I'll have to make an application, and have anyone who wants to grab their friends total actually install that app from within their own Facebook profile.
Anyone have any experience with this?
You can get friend count by fql easily.
There is a friend_count field against the user table that you can query.
SELECT friend_count FROM user WHERE uid = me();
https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid={any id}
You do need to set up an application, but it'll work as a Connect app - meaning that users won't have to access it through their Facebook profile at all. In broad terms you'll need to:
Set up an application
Implement Facebook Connect on
your site
Get users of your site to log in
with Connect. (You can't ask for
their username/password.)
Make a Friends.get call to the
API, probably with the JavaScript
client library (although there
are server-side ways you can do it)
Facebook provides an API for developers so you can grab information from Facebook. Check it out at the provided link.
Edit: From your tags, it looks like you are already familiar with the Facebook API. You can use the API with external applications or webpages - it doesn't necessarily need to be used within a Facebook app, if that is what you are asking.