Send private message using facebook API

In the last tutorial of facebook API I have explained you  Share application request with facebook API

In this tutorial I will explain you how to send private message using facebook api.
First you need to create facebook application. To create facebook application go to this this link
After creating the facebook application you will get a application ID. Note down the ID you will need it later on. Now click on the setting and fill the required field. You will see the add platform click on it and select website and fill your website url.
In next step click on the app details and select the category to games and subcategory anything.
now click on status and review and click on the yes button to activate the application.

Now create a file facebook.php and copy and paste the below code

<html xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
function message()
{
FB.init({appId: 'here your application ID', xfbml: true, cookie: true});
FB.ui({
method: 'send',
link: 'http://w3code.in',
}, function(response){
console.log(response);
});
}
</script>
<a href='#' onclick="message();"> send message</a>
</body>
</html>

Now run the facebook.php file and send message.
Hope this small tutorial of send private message using facebook API will help you.

  • Rishav

    Great article