I want to add some advanced permissions for django-facebookconnect, namely "email". After looking at the code, I see that the actual connection is controlled in javascript. So, I thought something like this might work
{% load facebook_tags %}
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function() {
FB.Facebook.init("{{ facebook_api_key }}", "{% url facebook_xd_receiver %}"{%extended_permissions%});
});
function facebookConnect(loginForm) {
FB.Connect.requireSession();
FB.Facebook.get_sessionState().waitUntilReady(function(){loginForm.submit();});
}
function pushToFacebookFeed(data){
if(data['success']){
var template_data = data['template_data'];
var template_bundle_id = data['template_bundle_id'];
feedTheFacebook(template_data,template_bundle_id,function(){});
} else {
alert(data['errors']);
}
}
function pushToFacebookFeedAndRedirect(data){
if(data['success']){
var template_data = data['template_data'];
var template_bundle_id = data['template_bundle_id'];
feedTheFacebook(template_data,template_bundle_id,function(){window.location.href=template_data['url'];});
} else {
alert(data['errors']);
}
}
function pushToFacebookFeedAndReload(data){
if(data['success']){
var template_data = data['template_data'];
var template_bundle_id = data['template_bundle_id'];
feedTheFacebook(template_data,template_bundle_id,function(){window.location.reload();});
} else {
alert(data['errors']);
}
}
function feedTheFacebook(template_data,template_bundle_id,callback) {
FB.Connect.showFeedDialog(
template_bundle_id,
template_data,
null, null, null,
FB.RequireConnect.promptConnect,
callback
);
}
</script>
here is the extended_permissions tag
@register.simple_tag
def extended_permissions():
if hasattr(settings,'FACEBOOK_EXTENDED_PERMISSIONS'):
return """, {permsToRequestOnConnect: "%s"}""" % ','.join(settings.FACEBOOK_EXTENDED_PERMISSIONS)
return ''
In theory, I think the above code should work. It actually works, it just violates the functionality of the popup. When the user receives a request from the application, he is redirected (inside the pop-up window) to the home page. Before editing, the popup will close and the main browser window will be redirected to / facebook / setup.
Any suggestions would be greatly appreciated.