Topic-icon Access FB info in own component?

Active Subscriptions:

None
11 years 3 months ago #30098 by playak
I used to have access to loads of FB info from my own component, using the JFBC libraries. Looks like it stopped working earlier this month. Did something on the FB side change?

For instance, I used to use:
	$events = $fbclient->api($fb->user."/events");
	$events = $events[data];

or even better (more details):
$fbparams = array('method' => 'events.get', 'start_time' => strtotime("-1 day"));
$events = $fbclient->rest($fbparams);

Since about a week or two, all I get in return is an empty $events array.

Anybody any clues or examples on how to get this working again?

Cheers,
Jeroen
The topic has been locked.
Support Specialist
11 years 3 months ago #30116 by alzander
Jeroen,
Not sure what would be happening there. Nothing's changed that we know of and our functionality built-in to JFBConnect hasn't had any issues recently.

The only thing I can think of is that you don't have the right permission to get event information. I know one change that Facebook recently implemented was "Create_event permission required to remove attendees from event". That change goes into effect in February with the February migration. JFBConnect will set that migration setting automatically in Autotune.

Beyond that, the best suggestion I can give would be to use the Facebook Debug Explorer tool. From there, you can generate access tokens (or use ones from JFBConnect) and test running the same api calls you're trying in JFBConnect.

Let us know if things have a different behavior in the Explorer tool, and hopefully that will help you narrow some differences down.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30124 by playak
Thanks. I turned on the output of error message and get the message:
COM_JFBCONNECT_FB_API_ERRORparameters uid or session key required
Would that help solving it?
The topic has been locked.
Support Specialist
11 years 3 months ago #30135 by alzander
Jeroen,
Can you edit the /components/com_jfbconnect/controller.php file. In the loginFacbookUser function at the top, you'll see the following block:
if (!$fbUserId)
        { # Facebook isn't returning information about this user.  Redirect them.
            $app->enqueueMessage(JText::_('COM_JFBCONNECT_UNABLE_TO_RETRIEVE_USER'));
            $app->redirect('index.php');
        }
Directly after that, add the following lines:
$fbClient = $jfbcLibrary->getFbClient();
        $fbClient->destroySession();
That can clear up some unnecessary Javascript Cookies that can cause issues with subsequent API calls. We're doing a lot of little changes to the access_tokens for the upcoming 5.0 release, and one of this is something similar to the above. Obviously, test a lot, and let us know if that has any affect (good or bad) on your calls.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30138 by playak
Thanks for that idea Alex. It seems to make things worse though. In my component, I call:

$fbclient->getMappedFbUserId();

And after doing your proposed mod, that function returns an empty string instead of my Facebook userid.
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30141 by playak
I managed to get the events list by using the graph API now: trick is that you have to use use me/events/not_replied as well as me/events/maybe and me/events/attending to get the full list.

Strange thing is that I still cannot get any results by using FQL. I just get an empty array by doing this:
	$fq = "SELECT eid, name, pic, creator FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid=me())";
	$fbparams = array('method' => 'fql.query', 'query' => $fq);
	$events = $fbclient->api($fbparams);

Also, I still get the COM_JFBCONNECT_FB_API_ERRORparameters uid or session key required errors, and the Facebook connection keeps disappearing every hour or so, also I stay logged in on the Joomla side as well as on Facebook.

Loads of work - pretty annoying.

Cheers,
Jeroen
The topic has been locked.
Support Specialist
11 years 3 months ago #30153 by alzander
Jeroen,
Glad to hear you got that going. The change I mentioned above is one of many little changes we're making to keep the access_token up-to-date and working. Some of the other changes may be necessary as well for what you're trying to do, but I don't have them all documented right now. The v5.0 release has better access_token management to ensure that it's always long-lived and shouldn't accidentally be expired when performing some Graph or FQL actions.

Let us know if you need more assistance, otherwise, I'd recommend waiting out v5.0 which should be out over the next 2 weeks.

Thanks,
Alex
The topic has been locked.