Search code examples
facebookfacebook-graph-apisocial-networkinginvite

need to invite facebook friends to mysite


I will implement a functionality that let users to invite their facebook friends (explicity choosing or let exclude some of them) to our site (I dont know what is possible with facebook api but possible cases: 1- sending plain email to friends 2- facebook message, invitation in facebook platform). I am facebook platform newbie and dont know where to start. Could you recommend which API should I use (facebook connect , facebook graph etc)? I read that facebook api and permission is changing rapidly. What is the state of the art way of doing this task?


Solution

  • You have to create one facebook app first.

    Heres the link for creating facebook app. https://www.facebook.com/developers/createapp.php

    Then after put the following code in your application.

    <div id="fb-root"></div>
        <script type="text/javascript">
        window.fbAsyncInit = function() {
            //Your app details here
            FB.init({appId: 'your-app-id', status: true, cookie: true, xfbml: true});
    
        };
    
    
        //Load the SDK asynchronously
        (function() {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
    
        }());
    
    
        </script>
    
    
    <fb:serverfbml>
        <script type="text/fbml">
            <fb:fbml>
                <fb:request-form
                                action="url-after-inviting"
                                method="POST"
                                invite="true"
                                type="Name of site"
                                content="Text you want to keep along.
                                    <fb:req-choice url='link-to-your-website'
                                    label='<?php echo htmlspecialchars("Invite Now!",ENT_QUOTES); ?>'/>"
                        >
                    <fb:multi-friend-selector
                                showborder="false"
                                actiontext="title-text"
                                exclude_ids="<?php //echo $excludeIds; ?>"
                                rows="3"
                            />
                </fb:request-form>
            </fb:fbml>
        </script>
    </fb:serverfbml>