I am wanting to add some extended permissions to django-facebookconnect namely "email". After looking through the code I see that the actual connect is managed in javascript. So, I thought that 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. Actually it does work it just breaks the popup window functionality. When the user accepts the request from the app they are redirected(within the popup) to the home page. Before the edits the popup would close and the main browser window would be redirected to /facebook/setup.
Any suggestions would be greatly appreciated