How do I get the Facebook Server Time? - facebook

I have created a facebook iframe app using Flash on the client and .net on the server. I am using fluorineFX to communicate between the two.
I need to get the exact facebook server time from my server. This is for authenticating the user on my server so I don't want to get the time from the client and then pass it to the server. This is the only interaction I need with Facebook from my server, all other interaction is handled by the client using the old rest API.
What is the best way to do this? I have read you can use FQL but seeing as its just the time I am looking for is there a way which does not involve getting an authToken on the server?
Thanks!
Tim

You can call now() in a Facebook FQL query to get the current Facebook server time in a unix timestamp and then convert it from there however you need.
For example, here is a sample FQL query that would work without an auth token (fql statements require a where clause so I just grabbed a random fql table with a random where statement):
SELECT now() FROM link_stat WHERE url = '1.2'
The url for that query would be:
https://api.facebook.com/method/fql.query?query=SELECT+now%28%29+FROM+link_stat+WHERE+url+%3D+%271.2%27&format=json
Facebook provides a FQL testing tool to help.

Related

Retrieval of user's likes using Facebook Graph API sometimes fails

in our game I'm checking if user is liking some of our Facebook sites.
For most users its working but there are some complaining that they are
having problems with this functionality.
1) I'm requesting "user_likes" permission during logging to Facebook
( users must be logged ).
2) I also take into account so called "paging" of result via Graph API.
( I'm retrieving all user's like-ids piecewise and after many tests
I assumed that it's working fine :o) )
3) Those users that were reporting that this check isn't working
really "like" those sites (before running this check).
So my assumption is that request "me/likes" fails or doesn't work
as expected under some conditions. Can someone help me with this
problem?
It seems that I'm not alone because I found these (unluckily unanswered):
https://stackoverflow.com/questions/10772814/checking-facebook-graph-api-for-user-likes-fails-for-some-users
http://facebook.stackoverflow.com/questions/10109773/cant-obtain-user-likes-in-some-cases-using-facebook-graph-api
The only cause I can think of is the Graph cache not being up to date with the user's Like data. If the user only just liked a page, and then you requested the Like data via Graph API, the data may not have been updated yet and therefore would show up as a "non-Liked" page.
Try using a FQL query to do the same check - but instead of paging through the user's like, do a direct check on the Page ID, User ID and Like status. You will have to join across multiple tables to get it working.

Personalized facebook graph API

I am using the Facebook graph API with queries like:
https://graph.facebook.com/search?q=term&type=post&access_token=XXXXXXXXXX
but I am getting different results when I execute a query via graph API and via the Facebook web...
I am using the same user (I get a access_token from the same user that I uses to search via web).
I tested this text query with dif. browsers and with a java client and I have the same problem....
I was searching information about this topic, but It was impossible to find something.
Finally, I'd like to ask if someone know how this query customizes its results and if it is possible to parametize it.
Regards.
Update:
I am testing a query as:
https://graph.facebook.com/search?q=mark&type=user&access_token=XXXXXXX
but I don't receive results. I don't understand how it is possible which Facebook doesn't find users named Mark..... I suppose I have to use some parameter (fields, f.e)... But It is not explained in the documentation....

Facebook Graph API FQL Query Limit

Is there an official limit (or at least a guaranteed rate) for Graph API calls?
I am getting valid access_tokens for users and use them both on web server and client side scripts. Both calls use FQL queries, which are like below:
SELECT+page_id+FROM+page_fan+WHERE+uid=me()+and+page_id=...&access_token=...
SELECT+post_id+FROM+stream+WHERE+(privacy.value='EVERYONE'+OR+privacy.value='ALL_FRIENDS')+AND+attachment.description='...'+AND+attachment.name='...'+AND+actor_id=me()+AND+source_id=me()+AND+is_hidden=0&access_token=...
I plan to query once every minute for each access_token and some will be made from client IPs, some from web server IP. So what exactly must I care?
And one additional question :) about the "me()" in those queries, if I make the calls from client or server does it differ? e.g. if the client user changes his/her FB login out of my web page, does it refer to new login or the login that the access_token had been generated?
When Facebook had app boxes and profile pages, My Countdown app updated the profile once per hour. At one point it had 400K users, thus was making 9.6 million (400K x 24) calls to Facebook per day.
I'm not sure if there is a limit, but the subscribe feature is suppose eliminate the need to hit their API so often. It sounds like you are trying to check if anything changed. The subscribe API call essentially tells Facebook to let YOU know when something changes.
Really, your issue is going to be network bandwidth and CPU, not Facebook limits.
The me() refers to the user/page ID encoded in the access token. Lint the token at https://developers.facebook.com/tools/debug and see what id it is for.

Querying FQL without user

I'm trying to get the number of recent checkins for multiple facebook places. I'd like to setup a CRON script that queries for recent checkins using something like:
SELECT tagged_uids FROM checkin WHERE timestamp > 1318514998 AND page_id IN (138444418096,138444418097)
But since this is a (fb userless) cron script, how can I get an access_token? I've tried getting one for a facebook app, but that didn't work.
You need to get an offline_access token and make sure that your script is on the same domain as your FB app that generated this token. BUT I don't think you can retrieve these info if you don't own the page.

How to get the list of friend_request using facebook API

How to get the list of friend_request using facebook API.
For example, user A,has logged in.
Use B send request of adding friends to A
Now, I want to get the friend_request of user A, how to do?
May the facebook graph API could not support the operate, yes or not?
At the same time, I would like to use FQL as below,
SELECT uid_from FROM friend_request WHERE uid_to=204686
(http://developers.facebook.com/docs/reference/fql/friend_request)
But, how to send the FQL to facebook server?which url?
like this:https://api.facebook.com/method/fql.query?query=select .... &access_token=....format=json... yes or not?
any other idea?
Thank you!
Simon
If you are using Java then why not use one of available Java Facebook APIs? Let API worry about which request to send where. Currently I am using RestFB API, there are plenty of examples on their site including how to execute FQL.
UPDATE
Ok, if you have to send requests manually then sending them using URL you provided is correct. Just remember that you would need to encode your FQL query before sending it as a param (URLEncoder in java would do the trick). You can play with the queries on this page and it will show you how your request should look like and what is returned.