Facebook canvas app - invite friends

I am writing an iframe / canvas application for Facebook and would like to give users the opportunity to invite friends to install this application. I am currently using Facebook's PHP-SDK to log in users and all interactions with Facebook. The only thing I can find about implementing the dialogue of invited friends is either related to FBML, which is deprecated; or request dialog: https://developers.facebook.com/docs/reference/dialogs/requests/ . The latter seems to require the use of the Facebook Javascript SDK, which has its own login methods.

Is the JS SDK my only option, and if so, how can I use this without forcing my users to log in again?

+5
source share
3 answers

Yes - Currently, the FB JS query dialog is the only way. And your users will not need to authenticate with your application - in fact, they will not need to authenticate with all this. I have a jsfiddle example with code that you can look at, but all you need to point out is your application id.

+2
source

first approach:

function newInvite(){
                 var receiverUserIds = FB.ui({
                        method : 'apprequests',
                        message: 'Come on man checkout my applications.',
                 },
                 function(receiverUserIds) {
                          console.log("IDS : " + receiverUserIds.request_ids);
                        }
                 );
                 //http://developers.facebook.com/docs/reference/dialogs/requests/
            }

Second approach:

<?php
     include_once "fbmain.php";
    if (isset($_REQUEST['ids'])){
        echo "Invitation Successfully Sent";
        echo '<pre>';
        print_r($_REQUEST);
        echo '</pre>';
        echo "<b>If you need to save these user ids then save these to database <br />then redirect user to the apps.facebook.com/yourapp url</b>";
        $string = "<script type='text/javascript'>top.location.href='{$fbconfig['appBaseUrl']}'; </script>";
        echo "Use the following javascript code to redirect user <br />";
        echo htmlentities($string, ENT_QUOTES);
    }
    else {
?>
<fb:serverFbml style="width: 500px;">
    <script type="text/fbml">
      <fb:fbml>
          <fb:request-form
                    action="<?=$fbconfig['baseUrl']?>/invite.php"
                    target="_top"
                    method="POST"
                    invite="true"
                    type="Demo Application  Learning API"
                    content="Checkout this demo application and learn iframe base facebook application development. <fb:req-choice url='<?=$fbconfig['appBaseUrl']?>' label='Accept' />"
                    >

                    <fb:multi-friend-selector
                    showborder="false"
                    actiontext="Checkout this demo application">
        </fb:request-form>
      </fb:fbml>
    </script>
  </fb:serverFbml>
<?php } ?>

third approach (using PHP-SDK):

     $app_id = "YOUR_APP_ID";

     $canvas_page = "YOUR_CANVAS_PAGE_URL";

     $message = "Would you like to join me in this great app?";

     $requests_url = "http://www.facebook.com/dialog/apprequests?app_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page)
            . "&message=" . $message;

     if (empty($_REQUEST["request_ids"])) {
        echo("<script> top.location.href='" . $requests_url . "'</script>");
     } else {
        echo "Request Ids: ";
        print_r($_REQUEST["request_ids"]);
     }
?>
+3
source

( 3.2) canvas-, .

, , FB apprequests FB v2

0
source

All Articles