I am getting Facebook comments data for particular posts using FQL. FQL returns only fromid however i need fromname as well. I am using batch request for getting comments of 50 posts at same time.
My query is
SELECT object_id,post_id,fromid,time,text,id,reply_xid,post_fbid,is_private FROM comment WHERE post_id='".$postID."'
How can I do this?
you need to make an additional query, something like this:
$multiQuery_postInfo = array(
"posts" => "SELECT post_id, actor_id, message, message_tags, likes, comments, share_count, attachment, action_links, type FROM stream WHERE source_id=$pageID",
"users" => "SELECT uid, username, first_name, last_name, profile_url, pic FROM user WHERE uid IN (SELECT actor_id FROM %23posts)"
);
Related
I am using FQL. I am using the following set of query to get info about album,
SELECT aid,src_small from photo where pid='100000244468314_1600187'
i get the following result,
{
"data": [
{
"aid": "0",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/545289_450190444999100_1364645489_t.jpg"
}
]
}
Then i gave the following query to get the album name and owner,
SELECT aid, owner, name, object_id FROM album WHERE aid="0"
But i get the following,
{
"data": [
]
}
Why is album id 0? and why it returns None? Please help. I am new to FQL
Try this query instead:
SELECT aid, owner, name, object_id FROM album
WHERE object_id IN
(SELECT album_object_id FROM photo where pid='100000244468314_1600187')
It looks like aid and pid fields are on their way to be deprecated in exchange for the object_id fields.
I'm developing an app that retrieves events via FQL from facebook Pages.
it happens sometimes that the owners of these pages do not create these events from the Page profile, but from their own profile and just link the event to the page as the field Venue (since the pages I'm looking for are public places)
is it possible via FQL or any other mean to get all the events ID that have as venue a specific facebook page ID??
now i can get all the events only if the page owners insert the events via the page profile with the following code:
$fql = "SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description
FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid IN ($clubsstring) )
AND start_time > $today
AND start_time < $nextweek
ORDER BY start_time asc";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
thanks
Luca
Well, you can indeed search based on venues, but that can only be a secondary condition since the venue field is not indexable.
This means that you first have to search based on eid (the only indexable field in the Event table), and then filter those results based on the venue.
The problem is that the venue field is an array, and the fields in it are not always there, for example one event might have this as venue:
"venue": {
"id": VENUE_ID
}
But another will have:
"venue": {
"street": "",
"city": "",
"state": "",
"country": ""
}
You should be able to get what you want with something like:
SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description
FROM event
WHERE
((eid IN (SELECT eid FROM event_member WHERE uid IN ($clubsstring)))
OR
(eid IN (SELECT eid FROM event_member WHERE uid IN (OWNERS_IDS_STRING)))
AND
venue.id IN (VENUE_IDS_STRING))
AND start_time > $today
AND start_time < $nextweek
ORDER BY start_time asc;
I haven't tested this query, and you might need to modify it a bit to work, also you can use a different field of venue other than the id.
Hope this helps.
I use this, it´s currently working.
{"eventos":"SELECT start_time, end_time, name, eid, pic,venue.id, location, creator, description
FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1=me() LIMIT 150)
OR uid = me() AND rsvp_status = 'attending') AND venue.id <>''
AND location <> '' AND location <> '#data'","lugares":"SELECT latitude,longitude
FROM place WHERE page_id IN (SELECT venue.id FROM #eventos)"}
I make a page tab application. The application displays some items, each of which has a like button. Like buttons attached to the corresponding url item. I need to display to users who liked, some text in those elements that have collected 10+ likes.
So, I write this code:
// Get a link statistics
$link_stat = $fb->api(
array(
'method' => 'fql.query',
'query' => 'SELECT like_count FROM link_stat WHERE url="http://myurl.com/item1.html"'
)
);
if ((int)$link_stat[0]['like_count'] > 10)
{
//Get like by current user_id and link object_id
$like = $fb->api(
array(
'method' => 'fql.query',
'query' => 'SELECT user_id, object_id FROM like WHERE user_id=me() AND object_id IN (SELECT id FROM object_url WHERE url="http://myurl.com/item1.html")'
)
);
var_dump($like);
}
I run this code upon request permission *user_likes* and *read_stream*, but it outputs array(0) { }.
A question is, how do I know the current user liked corresponding link?
Oh, sh… I didn't notice that there is a table url_like (or recently emerged?).
I made this FQL query, and it returned the required response:
SELECT user_id FROM url_like WHERE user_id = me() AND url = "http://myurl.com/item1.html"
Cpilko, thank you very much! =)
You could try rewriting your query to go at it the other way. See if your url exists in a user's likes.
This works for me:
SELECT url, id, type, site FROM object_url WHERE id IN (SELECT object_id FROM like
WHERE user_id=me()) AND strpos(url, "myurl.com/item1") >= 0
I need fetch user's friends data with next fields: id, name,
gender, birthday, city, country, profileUrl, pic, pic_small,
pic_big, is_app_user.
Before I used FB.Data.query, but now it's deprecated.
FB.Data.query('select uid, first_name, last_name, name, pic,
pic_small, pic_big, birthday_date, sex, current_location,
profile_url, is_app_user from user where uid in (select uid2 from
friend where uid1 = {0}', uid).
How to fetch friends, who are using app?
I can get all fields what i need, but for example for pictures i need to do additional requests. Can i get all needed fields in single request?
You can still use same FQL query with Graph API and JavaScript SDK
var query = 'SELECT uid, first_name, last_name, name, pic, pic_small, pic_big, birthday_date, sex, current_location, profile_url, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ' + uid;
FB.api('/fql',{q:query}, function(response){
console.log(response.data);
});
You for sure can also get almost same data with Graph API not using FQL at all:
FB.api('/'+uid+'/friends', {
fields: 'id,first_name,last_name,name,birthday,gender,location,link,installed'
}, function(response){
console.log(response.data);
});
You have a bit different names and other format (ex location) for those details and miss the picture details in results but this is simple, user picture is available on URL in form http://graph.facebook.com/USER_ID/picture
use ?type=square | small | normal | large to request a different photo
I've been poking around with this too, using PHP. This is what I came up with:
$user_friends = $facebook->api('/me/friends?fields=installed');
$user_players = array();
foreach ($user_friends['data'] as $userfriend)
{
if (array_key_exists('installed', $userfriend))
{
array_push($user_players, $userfriend);
}
}
The Following Helps you to fetch user's friend details using graph api
NSString friendId =10020020 //Store Friend ID;
NSString * pRequestString = [NSString stringWithFormat:#"%#?fields=name,picture,work,hometown,birthday,devices,interests",friendId];
[[FBRequest requestForGraphPath:pRequestString ] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(#"%#",result);
}];
I am trying to achieve the following via Facebook's Multiquery FQL, get a list of all Fan Page Events that i am 'Attending'.
I have the below logic, and have tried to implement something similar with the FQL statement below.
get list of all events created by / from a Fan Page (using specific id)
get a list of all my (the users) events attending
Match eid's from event_member FQL Table
If they match ids, and rsvp_status is equal to attending
display result.
FQL Multi
{"query1":"SELECT eid FROM event WHERE
eid IN (SELECT eid FROM event_member
WHERE uid
=$fanpageID)","query2":"SELECT rsvp_status FROM event_member WHERE
uid = $uidAND eid IN
(SELECT eid FROM #query1)"}
I know the statement is incorrect, but i am struggling on trying to do this. I have achieved this via Graph API using a very messy set of foreach loops in my PHP code.
Using a single multiquery FQL statement would be far more efficient.
Any suggestions would be great.
EDIT
Problem im having now, is ifaour's FQL statement works within the FQL Query console (Returns Results), however when i run the following, and empty array is returned.
When i dissect the statement to just ( SELECT eid FROM event WHERE creator =$fanPageID) the FQL Console highlights that eid in non indexable.
Here is my PHP
function usersEventsPoints($uid,
$facebook, $fanpageID){
$events = "SELECT eid FROM event WHERE creator=$fanpageID AND eid
IN (SELECT eid FROM event_member WHERE
uid=$uid AND rsvp_status =
\"attending\")";
$eventsAttendance = $facebook->api(array(
'method' => 'fql.query',
'query' =>$events, ));
$eventsAttendingcount = 0;
foreach
($eventsAttendance as $eventsAttendanceFetch) {
if($eventsAttendanceFetch['eid'] == true){
$eventsAttendingcount++;
}
}
return $eventsAttendingcount;
}
Blockquote
Any Ideas?
It's a very simple task:
SELECT eid FROM event WHERE creator = $fanpageID AND eid IN (SELECT eid FROM event_member WHERE uid = me() AND rsvp_status = "attending")
This will return all events' Ids that are created/owned by the page that has $fanpageID id and you are a member in (me()) and your status is attending.
EDIT:
You are looping the returned array just to get the count?! you can simply use:
$eventsAttendingcount = count($eventsAttendance);
Also make sure that the user you are matching, has authorized your application and granted you the correct permission!
I'm not sure I understand what the problem is - I ran your FQL statement and it returns a list of events and then your RSVP status?
On another note, why not use the events.get method. You pass in the UserId and it will display the event information for you. You can filter by RSVP status.
Just checked and the events.get method is in the process of being deprecated.
You should use the new Graph API which gives you a list of attendees for your event:
http://developers.facebook.com/docs/reference/api/event
You get the list of attendees by using
https://graph.facebook.com/EVENT_ID/attending
If you want to get the next 10 events of the facebook logged user where events are set a attending then you can build your Swift query like this:
let graphPath = "/me/events?limit=10&type=attending&since=now"
let params = ["fields": "id, name, category, start_time, end_time, timezone, updated_time, type, attending_count, owner, place"]
let request = GraphRequest(graphPath: graphPath, parameters: params, accessToken: accessToken, httpMethod: .GET, apiVersion: apiVersion)
request.start {}