Question

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.

  1. get list of all events created by / from a Fan Page (using specific id)
  2. get a list of all my (the users) events attending
  3. Match eid's from event_member FQL Table
  4. If they match ids, and rsvp_status is equal to attending
  5. 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?

Was it helpful?

Solution

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!

OTHER TIPS

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 {}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top