Similar unanswered question, however this question focusing more on where to proceed to now. I am led to believe that there is a bug with Facebook's FQL because the event_member table never returns a non-null answer for "inviter", [tested large and small events, public & private, and self admined events]. There are no reported "inviter" bugs on Facebook's site, and no references elsewhere on the internet. Is it common for Facebook to have an error in their graph ( I should hope not)? Could it be this is now depreciated (With no mark of it's existence)? Should I wait it out or keep trying? If it is a brand new feature of event_member, should there not be a news release etc?
TRY this example on Facebook's FQL explorer: https://developers.facebook.com/tools/explorer?fql=select%20inviter%2C%20inviter_type%2Cuid%2C%20rsvp_status%20from%20event_member%20where%20eid%20%3D%20321938874572158%3B
TL;DR: This doesn't work:
Select inviter, inviter_type,uid, rsvp_status from event_member where eid = 321938874572158;
The graph returned for the inviter field only reports the ONE person who FIRST invited YOU, not anyone else. If you created the event yourself, or "attended" the event without an invite (such as by finding the link), then you wont have an "inviter". So to answer your question, there is not a "crippling bug".
For the part of actual graph results returned shown below:
I have been invited 3 times,though only one ID shows up.
It has a privacy level of "friends of friends".
I am attending.
The command used was SELECT uid, rsvp_status, inviter FROM event_member WHERE
eid=5612079XXXXXXXX;
{
"uid": 51454XXXX,
"rsvp_status": "attending",
"inviter": null
},
{
"uid": 3124XXXX,
"rsvp_status": "attending",
"inviter": 16498XXXX <------ HERE IS MY INVITE, FROM ANOTHER USER
},
{
"uid": 127868XXXX,
"rsvp_status": "attending",
"inviter": null
},
{
"uid": 164982XXXX,
"rsvp_status": "attending",
"inviter": null
}
This is what I can see after testing with my own events and events created by others:
The event_member table's inviter field will return null for the user who is the event creator.
For example, a hypothetical event with eid 111 was created by John who has uid 222. Then John invited Jane who has uid 333.
When we query:
select uid, inviter from event_member where eid=111
we receive:
{
"data": [
{
//Jane's data
"uid":333,
"inviter": 222
},
{
//John's data
"uid": 222,
"inviter": null
}
]
}
So, all users except the event creator has a non-null inviter value.
I don't know if this all tallies with your findings or if what you've found is a different issue/bug.
Related
Since Facebook API update to v2.11, I cannot get User Id and Name from comments on FanPage Wall Post. Anyone can help/explain?
Usually I used this :
https://graph.facebook.com/[POST_ID_PAGE]/comments?order=reverse_chronological&access_token=[YOUR_ACCESS_TOKEN]
And the result just like :
{
"data": [
{
"created_time": values_date_TMZ,
"from": {
"name": USER_NAME,
"id": USER_ID
},
"message": THE_COMMENT,
"id": THE_COMMENT_ID
}
}
You need a Page Token now, to get user names - check out the changelog:
https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi
I assume you are using an App Token at the moment.
Edit: Of course it has to be a Page Token of the Page with the comment. And of course you need to manage the Page - else you would not even get a Page Token.
When I'm getting a status/link/photo from facebook API, how do I know if it has been shared with the public or if it's a private post?
Also - is there a way to query only public posts?
I'm currently using the /<username>/status /<username>/links /<username>/photos endpoints.
With the graph api
From the 3 endpoints you are using, only one gives you access to the privacy settings the /<username>/links. It returns a privacy object, something like this:
{
"id": "USER_FB_ID",
"links": {
"data": [
{
"id": "ID_OF_THE_POST",
"from": {
"name": "Fábio Antunes",
"id": "USER_FB_ID"
},
"message": "Check this awesome link",
"privacy": {
"description": "Friends; Except: Restricted",
"value": "ALL_FRIENDS",
"allow": "",
"deny": "",
"networks": "",
"friends": ""
},
(etc....)
With FQL
To solve your problem you could use FQL this way you can get the 3 endpoints that have public access.
For the links you can use this query:
Select link_id,owner_comment, title, url, privacy FROM link WHERE owner = me() AND privacy.value='EVERYONE'
note: check the link table to see if there are any fields that you may want to add to this query
Since the links table from the 3 endpoints is the only with privacy settings structure to get the user photos and statuses that are public you will have to use the privacy table.
To get all the users public photos I made 2 joins, first I'm getting the user photos, then I want the privacy settings of the photos that are available to everyone and then I select the photos that have the privacy settings public:
SELECT caption,src_big FROM photo WHERE object_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT object_id FROM photo WHERE owner=me()))
note: check the photo table to see if there are any fields that you may want to add to this query
To get the public statuses it's the same process for the photos, two joins:
SELECT status_id , message, place_id FROM status WHERE status_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT status_id FROM status WHERE uid=me()))
note: check the status table to see if there are any fields that you may want to add to this query
There is the question about fetching count of user friends via FaceBook API.
I want to get the number of friends only have USER_ID of the any facebook user. As I know I can get it using FQL like:
SELECT friend_count FROM user WHERE uid = X
But for some users this value is null or there is no value. Please advice is there another way to get this value?
That user might be keeping that information private. In that case, you cannot fetch that information.
You just check the following link. You need to generate token (by clicking on Get Token you will get it) with data you want from facebook API, need to select friends option to get the friend count.
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname%2Cfriends&version=v2.8
FB.api(
'/me',
'GET',
{"fields":"id,name,friends,link,email,gender,picture,first_name,last_name,cover"},
function(response) {
// Insert your code here
}
);
after executing this you will get this in response as
{
"id": "XXXXXXXXXX",
"name": "Test test",
"friends": {
"data": [
],
"summary": {
"total_count": 14
}
}
}
total_count will be your friend count
In the description of the FQL event_member page, it says that the column inviter should inform us about the ID of the user or page who invited a UID at the event, and inviter_type should inform us about whether the inviter was a user or a page. I have tried these functions on both public events and an event that I have created myself, but it always fails.
"inviter": null and "inviter_type": "" for every user.
Is this a bug, an old function that works no more, or a new function that does not work yet?
It seems that you only are allowed to know who invited you and how.
The only command that will make the inviter and inviter_type attributes useful is:
select eid, uid, inviter, inviter_type, rsvp_status
from event_member where eid=EVENT_ID and uid=me()
In that case, you are exactly looking for the person who invited you to an event you've been invited to!
Result:
{
"data": [
{
"eid": 3811052099231,
"uid": 1022369839,
"inviter": 1406101549,
"inviter_type": "user",
"rsvp_status": "attending"
}
]
}
The Facebook Graph API provides a user's current location in two formats: name and ID. ID can be something like 104022926303756. Name can be something like Palo Alto, California or Beijing, China. From these two fields, how do I extract the country? All American locations are in the form [City], [State] whereas all non-American locations are in the form [City], [Country]. Can I code something less hacky than:
$states = array(
'Alabama'
'Alaska',
'Arizona',
// ...
);
$country = 'USA';
if (!in_array($locationName, $states)) {
preg_match('#, ([a-z]+$)#i', $locationName, $match);
$country = $match[1];
}
How about using this: http://developers.facebook.com/tools/explorer/?method=GET&path=fql%3Fq%3DSELECT%20current_location%20FROM%20user%20WHERE%20uid%3Dme()
?
As you can see, using FQL on user table, the JSON you'll receive is something like:
{
"data": [
{
"current_location": {
"city": "Turin",
"state": "Piemonte",
"country": "Italy",
"zip": "",
"id": 115351801811432,
"name": "Turin, Italy"
}
}
]
}
There you have the field country, much more readable :-)
EDIT: The link is broken because brakets are missing at the end of query, anyway the FQL query is:
SELECT current_location FROM user WHERE uid=me()
"me()" can be any user ID.
If you want more information you could use the latitude and longitude from https://graph.facebook.com/104022926303756 and feed them into a reverse geocoder.
http://maps.googleapis.com/maps/api/geocode/json?latlng=37.4293,-122.138&sensor=false
The Google API gives a lot of information, but it can be quite useful.
The country code may be a better idenfifier than the country name for example.
There's also the possibility to select output language. Adding &lang=sv gives you "Kalifornien" as the name of the state instead of "California".
It comes inside the signed request when they hit your app. It comes even when they still didn't approve your app.