Topic-icon Request Photos Permissions Button

Active Subscriptions:

None
12 years 5 months ago #39685 by Ivan
Alex, at the point where I ask for permission the user is logged in already. I already have the settings you recommended above. What I need to do is reload the page.
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago - 12 years 5 months ago #39689 by Ivan
Now that I have added this code an initialized the FB Cliente I am sometimes getting

COM_JFBCONNECT_FB_API_ERRORAn active access token must be used to query information about the current user.


AS for the code below it seems to be javascript. Is there a php way

alzander wrote:

var hasPermission = jfbc.permissions.check('user_photos');
That will return true if the user has the permission.

It will return false if:
a) the user isn't logged in using Facebook (or not logged in at all)
b) the user doesn't have that permission.

In either case of false, the user can click the button you created above to get the permission (and possibly log them in).

I hope that helps,
Alex


Is there code to do this via php
Last edit: 12 years 5 months ago by Ivan.
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago #39769 by Ivan
Alex,

Is there a way to check if you have photos permission using php? What class would I need to initialize in my component?
The topic has been locked.
Support Specialist
12 years 5 months ago #39789 by alzander
I don't have the exact code on me right now. When a user logs in with Facebook, we store a session cookie in their browser called "jfbconnect_permissions_granted". That cookie has a JSON array of permissions for the user, like:
["installed","basic_info","user_photos"]
With PHP, you should be able to fetch that cookie, check if it exists and then parse out the permissions the user has granted to respond accordingly. The cookie is automatically updated anytime the user logs in or you have them re-authenticate (to update their permissions).

I hope that helps get you started, but if not, just let me know.

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

None
12 years 5 months ago - 12 years 5 months ago #39794 by Ivan
Okay,
The following code does seem to check for permissions; however when I click on the link you gave me the permissions for photos comes up and when I accept it does not reload the page.
$cookie = $_COOKIE['jfbconnect_permissions_granted'];
$cookie = json_decode($cookie);

if (!in_array("user_photos", $cookie)) {

Put link here

}

<a class="btn btn-large btn-primary" href="javascript:void(0)" onclick="jfbc.permissions.update_scope('user_photos'); jfbc.login.facebook();">Import Facebook Albums</a>


The code above does not cause the page to reload.
Last edit: 12 years 5 months ago by Ivan.
The topic has been locked.
Support Specialist
12 years 5 months ago #39853 by alzander
Is that code properly asking the user for the photos permission? Not sure why the page wouldn't reload if so.

The next thing would be to turn the "Enable Debug Mode" in JFBConnect on. Then, check the Javascript console and let me know what messages appear there. That will help narrow down what JFBConnect thinks is happening.

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

None
12 years 5 months ago #39864 by Ivan
Alex,

I do have debug mode on and it just doesn't say any error and there isn't any JavaScript error. I will email you the link to test this out but it will require a few steps
The topic has been locked.