I need to get my UID using a simple FQL query, for some reason it returns an empty page.
This is my query:
https://api.facebook.com/method/fql.query?query=SELECT uid FROM user WHERE uid=me()
me() returns the current connected user. So you need to append an access_token:
https://api.facebook.com/method/fql.query?query=SELECT uid FROM user WHERE uid=me()&access_token=XXXXXX
P.S.: Facebook has just released a Graph API endpoint to query FQL fql, so you should be able to do something like:
https://graph.facebook.com/fql?q=SELECT uid FROM user WHERE uid=me()&access_token=XXXXXX
(unfortunately, for some reason it's not working on the Facebook Graph Explorer)
Related
How can i get the user id from facebook url and get the basic info ?
This will be possible if i use the http://www.facebook.com/[username] '
In order to get the ID of a Facebook User, you need to authorize the User: https://developers.facebook.com/docs/facebook-login/
After that, you will get an "App Scoped ID" for that User with this API endpoint: https://graph.facebook.com/me?access_token=[user-token]
It is NOT possible to get the ID of a user by his username (or URL). Scraping is not allowed on Facebook - that i what some platforms do. But you do not need that ID anyway, you can just use the App Scoped ID instead.
Is there a way to add user-data (a number or a string) and use it while querying posts from the stream of that page ?
Essentially I am trying to make posts with certain attributes on a Facebook page thru an App and would like to query the stream (newsfeed) on that page using FQL or Graph API and just select the specific posts based on the attributes added to the posts.
SELECT post_id FROM stream WHERE **user_data** ='tag-specified-with-post' app_id='APP_ID'.
Thanks for your help.
Use FQL to get posts from your app. This query will get posts made in the account of the user by the Photos app:
SELECT app_id, post_id, actor_id, target_id, message FROM stream WHERE filter_key ='owner' AND is_hidden = 0 AND app_id='YOUR_APP_ID'
Replace that app_id with yours. And replace filter_key with 'others' to get other people's posts that the user can view.
I can access the tags associated with a particular photo via the Graph API, but if I try to query the photo_tag FQL table I get an empty response. I'm using the same access token in each case (testing this in the Graph API Explorer).
For example, if the pid is 123, then https://graph.facebook.com/123/tags shows me the tags that I want to see, but select text from photo_tag where pid = '123' returns nothing.
Is this a bug or did something recently change with Facebook Platform and I'm missing something here?
Your id 123 is probably an object_id instead of a pid.
Try this query instead:
SELECT text FROM photo_tag WHERE object_id = 123
I have successfully retrieved up to 50 user's profiles using the batching method. I attempted to use the same process to retrieve these user's profile photos, but get an error 302. I see that there is a URL pointing to the photo returned in the result, but using that to retrieve each photo would defeat the purpose of batching, which is to retrieve all at once and prevent repeated HTTP requests. Is it possible to retrieve these using the batching in the Facebook API?
Try FQL:
SELECT pic_square FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
...where pic_square can be one of pic_small, pic_big, pic_square, pic
That'll give you URLs for the corresponding user's profile picture at the given size.
e.g.:
https://developers.facebook.com/tools/explorer/?method=GET&path=fql%3Fq%3DSELECT%20pic_square%20FROM%20user%20WHERE%20uid%20IN%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29
So in my app, I do this:
FB.api('/me', function(response) {
alert(response.name);
});
This gives me the users name IF they are logged into FB through my site. Now, is there a way I can get a unique ID for them as well? That way everytime they post something on my site, I can store their post along with their FB name AND Id, and then I know which posts they have made in the past when they are connected to their FB through my site.
You can use response.id to get the Facebook Users unique id.