views:

1836

answers:

3

Note: The application I'm building is a website type Facebook Application that uses Facebook Connect.

I can prompt the user with a request for Extended Permissions using the following FBML code:

<fb:prompt-permission perms="read_stream,publish_stream">
    Grant permission for status updates
</fb:prompt-permission>

Taken from here.

This creates a link on the page that must be clicked by the user in order to trigger the prompt to display.

My question is:

Is it possible to display this prompt automatically, when the page loads, without requiring the user to click on the link?

Also, in reply to the answer below, I'd like to avoid displaying the link. Would prefer a neat way to do this, if that fails the least dirty method will do :-)

+2  A: 

Sure, just programatically click the link when the page loads:

window.onload = openpermissions();
function openpermissions(){
document.getElementById('permlink').onclick();
}

[http://wiki.developers.facebook.com/index.php/UsageNotes/Forms#Prompting%5Fa%5FUser%5Ffor%5Fan%5FExtended%5FPermission%5D%5B1%5D

Javascript Version:

http://forum.developers.facebook.com/viewtopic.php?id=42195

<script type="text/javascript">
    Facebook.showPermissionDialog('read_stream, photo_upload', ondone);
</script>

ondone is a function callback.

By calling FB.Connect.showPermissionDialog, for use with IFrame applications and Facebook Connect sites. For Facebook Pages, you can prompt only for the publish_stream permission using this method.

http://wiki.developers.facebook.com/index.php/Extended%5Fpermissions

CodeJoust
I'd rather not display the link on the page. Though I suppose I could `display:none` the link and go dirty :-)
Rew
Tryhttp://forum.developers.facebook.com/viewtopic.php?id=42195
CodeJoust
Thanks CodeJoust, I'll look into this, I've come across examples that are for Canvas based applications that didn't work for Website/Connect based ones. Will try this and see...
Rew
Updated response with the right function, I didn't know you were using FB Connect.
CodeJoust
A: 

This is what you need... Use a fb:redirect tag after checking for the permission - Try using:

http://www.facebook.com/authorize.php?api%5Fkey=YOUR%5FAPP%5FKEY&amp;v=1.0&amp;ext%5Fperm=status%5Fupdate&amp;next=A%5FLINK%5FTO%5FYOUR%5FAPP

Where your_app_key is your facebook app_key.

Alex
A: 

You can make a javascript function that check for permission and ask for permission if needed.

Check with "users_hasAppPermission" method and ask with "showPermissionDialog" method, you can call your function with the "onload" attribute on the tag od your html, I think it's better instand of click on links programmatically.

I found a function here in S.O. but now I can't find it again, but I've used it on a tutorial here.

Pons

related questions