get inbox message by facebook sdk in php

<?php
include “src/facebook.php”;
$facebook =new Facebook(array(
‘appId’=>’appid’,
‘secret’=>’secret’,
‘cookie’=>true
));
$session=$facebook->getUser();
$me=null;

if($session)
{
try
{
$me=$facebook->api(“/me/inbox/”);
//    print_r($me);

foreach($me as $noti)
{
foreach($noti as $a)
{
foreach($a as $b)
{
foreach($b as $c)
{
foreach($c as $d)
{
foreach($d as $e){
if(isset($e[‘name’])){
echo $e[‘name’].”:-“;

}
}
if(isset($d[‘message’])){
echo $d[‘message’].”<br>”;
}
}

}
}
}
}

}catch(FacebookApiException $e)
{
echo $e->getMessage();
}
}
if($session)
{
$logoutUrl=$facebook->getLogoutUrl();
echo “<a href=$logoutUrl>Logout</a>”;

}
else
{
$loginUrl=$facebook->getLoginUrl(array(‘scope’ =>’publish_stream,read_stream,manage_notifications,read_mailbox’));
echo “<a href=$loginUrl>Login</a>”;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s