English 中文(简体)
Facebook FQL - All fanpage Events a User is Attending
原标题:

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?

最佳回答

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 {}




相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签