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/
Related
From various postings I know that the timestamp of a 'like' is stored by FB, notably from here:
https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes/
But what I'm having trouble getting clear is how, given a photo that's been posted to an event, I would get all the picture's likes and the time each like was created (and of course, by who).
As far as I can tell it would have to go something like this:
Get each user invited to event.
Get each user's likes.
Check if any of the fbid's of the likes match any of the event photos' id's.
But surely step 2 would necessitate me logging in on behalf of each invited user and anyway, wouldn't the above really poll FB too much? So I am assuming my procedure is incorrect.
Could anyone tell me what the fql would be to get a photo of an event and then the users who like the photo and then the timestamp of the like?
Thanks in advance!
Short answer, you can't. The FQL or Graph API doesn't provide such information.
There are two things to differentiate in Facebook for developers:
The FQL or Graph API, which lets developers access the Facebook data (it means everything hosted on Facebook servers and saved in Facebook databases) like events, photos, videos, posts, etc.
Open Graph, which lets apps tell on Facebook what happened on the app side : we are talking about the app's own content and requests.
When trying to grab information from an event (content managed by Facebook), you are in the first case. As you can see here, here or here, likes are never described by a timestamp.
What you saw here deals with Open Graph, which can't be applied on Facebook events.
I'm tryin to develop a (almost) 100% client-side dynamic website by integrating it with twitter, facebook and flickr.
I've been able so far to get the last 4 tweets (with javascript) from my client's feed, and now i was wandering if i could do the same with facebook's gallery and events from their feed.
Especially, what i need (given the facebook username/api key/whatever)
gallery
for each gallery in user's profile:
get the gallery name
get the first picture
get the gallery url
news/events
for each news/event/post in user's profile:
get the event name
get the event text
get the event picture (if provided)
get the event url
I don't want to use the facebook widgets with their rendering, i just need to read the json response (if there's any) and put the data inside my website (like a preview).
Since my client is pretty rusty with "computers (cit.)" but he's (not so strangely) comfortable with facebook/twitter/flickr, i tought about a solution like this before adding a database and an admin interface to our website.
I found some resources online, so i think it's possible (in a way or another). I'd like to do it in javascript, but if it's php i won't complain.
Check out this API to get photoes from the user profile
http://developers.facebook.com/docs/reference/api/album/
This is for events
http://developers.facebook.com/docs/reference/api/event/
You can use either the PHP or the Javascript API SDKs:
http://developers.facebook.com/docs/reference/php/
http://developers.facebook.com/docs/reference/javascript/
respectively. Naturally you would handle the returned information differently. Both have a method called api() which can be utilised to grab the album and event objects (as mentioned in another answer):
http://developers.facebook.com/docs/reference/api/album/
http://developers.facebook.com/docs/reference/api/event/
You can pass parameters in the methods to restrict the results returned by fields, number of items, sizes of images etc. This is outlined here:
http://developers.facebook.com/docs/reference/api/
But the issues you are going to face is that you have to authorise your "app" - think website when they use the terminology "app" - to give it permissions to access the information. This takes the form of a two step process. You have to create the app on the Facebook platform which can then access the API methods (only certain information can be got from the API methods without an authenticated app).
The second part is that the user themselves must then authenticate their facebook account against your app - this gives your app permission to access the user's information. In plain English it would go like this:
User visits your webpage; user must be logged into Facebook and must approve your app (this used to be called Facebook Connect for obvious reasons); the app and the user account are "connected"; the app can then use the api methods you've written to return information about the connected user
The beginning explanations of how to do this are here:
http://developers.facebook.com/docs/authentication/
The only way you can access a user's (non-public) information from outside of Facebook is via a connected app and user profile.
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.
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