IT Certificaions

Google Cloud Platform

Tuesday, January 17, 2012

Facebook JavaScript API: Invite facebook friends

This is the JavaScript code to invite facebook friends (Posting message to their wall)


function inviteFBFriend(friend_id,invitation_message){
var opts = {
             message : invitation_message,
             name : 'Hello User',
             description : 'Facebook is great!',
             picture : 'http://www.knowledgeserve.in/images/knowledgeServeLogo.jpg'
    };

FB.api('/'+friend_id+'/feed', 'post', opts , function(response) {
       if (!response || response.error) {
        alert('Error occured');            
       } else {
           alert('Post ID: ' + response.id);
       }
     });


}