Topic-icon Request Photos Permissions Button

Active Subscriptions:

None
12 years 5 months ago #39493 by Ivan
When I first connect I just grant users permission for the email, friends list. However when a user wants to upload a photo on my site I want them to request photos permission. I have this code:
<fb:login-button v="2" perms="user_photos" onlogin="javascript:jfbc.login.login_custom();">Access Facebook Albums</fb:login-button>

However the pop up is shown and after the button is pressed the pop up is gone, but the page is not reloaded. I need the page to reload so that the albums appear once permissions are granted. Is there anyway to achieve this, perhaps other code?
The topic has been locked.
Support Specialist
12 years 5 months ago #39507 by alzander
Try:
<a href="javascript:void(0)" onclick="jfbc.permissions.update_scope('user_photos'); jfbc.login.provider('facebook');">Login</a>
That should add 'user_photos' to the current required scope and popup the login box with any permissions the user hasn't set. That also will allow new users to click the button and have all their scope set at that time.

Let me know if that helps, or not, and good luck!
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago #39520 by borfle
Hi, sorry to cut in, but where do I need to add this code? Thanks.
The topic has been locked.
Support Specialist
12 years 5 months ago #39523 by alzander
You can put that code anywhere. All that code will do though is show a "Login" link which, when clicked, will ask the user for the standard set of permissions that JFBConnect requires along with the new one, "user_photos". It won't actually 'do' anything with the user photos. That's up to you to implement in code in some way. We just have an easy method to be able to fetch and update a user's permissions so that you can add your own features as necessary.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago - 12 years 5 months ago #39566 by Ivan
I get a TypeError: jfbc.login.provider is not a function. I am 2 versions below what is out.


jfbc.permissions.update_scope('user_photos'); jfbc.login.provider('facebook');



Also What code would be called to check for this permission. Could you give insight.
Last edit: 12 years 5 months ago by Ivan.
The topic has been locked.
Support Specialist
12 years 5 months ago #39574 by alzander
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
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago #39585 by Ivan
okay, what about the reason I am getting an error when I click the link you gave me. I get TypeError: jfbc.login.provider is not a function

I am 2 versions below what is available for 2.5
The topic has been locked.
Support Specialist
12 years 5 months ago #39610 by alzander
I'm assuming you just mean v5.2.0 (and not something like v5.0.0). The permissions checking feature was added in v5.1.0. The provider('facebook') option was added in v5.2.0. If you're still on v5.1.0, replace:
jfbc.login.provider('facebook');
with
jfbc.login.facebook();
I hope that helps!
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 5 months ago #39621 by Ivan
OKay, the code seems to work but doesn't reload the page where it its. I would like to reload the page.
The topic has been locked.
Support Specialist
12 years 5 months ago #39627 by alzander
That code sends the user through the standard JFBConnect login process if they aren't logged in. For now, you'd need to set the New User Redirection and Returning User Redirection to "Same Page" to keep the user on the same page.

We're planning to a redirection option to that code in a future update so that the config options can be overwritten.

I hope that helps,
Alex
The topic has been locked.