$fbClient = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $fbClient->getFbUserId();$cookie = $_COOKIE['jfbconnect_permissions_granted'];
$cookie = json_decode($cookie);
if (!in_array("user_photos", $cookie)) {
Show Button Code here
}
function getAlbums ()
{
try {
return $this->api('me/albums');
}
catch (Exception $ex) {
return array();
}
}
$albums = $fbClient->getAlbums();
<div class="sourcecoast" style="margin-top:6px;text-align:center;">
<a class="btn btn-large btn-primary" href="javascript:void(0)" onclick="jfbc.login.facebook(); ">Import Facebook Albums</a>
</div><div class="sourcecoast" style="margin-top:6px;text-align:center;">
<a class="btn btn-large btn-primary" href="javascript:void(0)" onclick="jfbc.permissions.update_scope('user_photos'); jfbc.login.provider('facebook');">Import Facebook Albums</a>
</div>if (!jfbc.login.logged_in)
jfbc.login.facebook_onlogin();
else
jfbc.permissions.fetch();if (!jfbc.login.logged_in)
jfbc.login.facebook_onlogin();
else
{
jfbcJQuery(document).one("jfbc-permissions-fetched", function () {
location.reload(true);
});
jfbc.permissions.fetch();
}alzander wrote: Ivan,
I just looked at our code to come up with the best solution. I think the following should work, but you'll have to test. Please edit the /components/com_jfbconnect/includes/jfbconnect.js file. Around line 46, you'll see:Update that to:if (!jfbc.login.logged_in) jfbc.login.facebook_onlogin(); else jfbc.permissions.fetch();The jfbc-permissions-fetched event is called after the new permissions are grabbed and set into the cookie. Then, the location.reload should reload the page. That will let your PHP code be able to see the updated cookie and do what it needs to do.if (!jfbc.login.logged_in) jfbc.login.facebook_onlogin(); else { jfbcJQuery(document).one("jfbc-permissions-fetched", function () { location.reload(true); }); jfbc.permissions.fetch(); }
Please test and let me know how that goes. I didn't test directly, but the code looks good from what I can tell.
Thanks, and good luck,
Alex
<a class="btn btn-large btn-primary" href="javascript:void(0)" onclick="jfbc.permissions.update_scope('user_photos'); jfbc.login.provider('facebook');">Import Facebook Albums</a> function getAlbums ()
{
try {
return $this->api('me/albums');
}
catch (Exception $ex) {
return array();
}
}Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.
