在我的网站上使用我的Facebook应用程序的用户会查看他的一些朋友(没问题)。然后我需要让他们知道他们有来自该用户的新消息。我怎样才能让他们知道这件事?通知?私信?贴在墙上?我认为通知(到全球顶部区域)会很好,但如何使用PHP图形
您应该为此使用请求对话框。请参阅此处:
Facebook请求对话框
您可以向已验证您的应用程序的人发送通知。唯一的问题是,这会创建一个只会出现在用户"应用程序和游戏"通知中的通知——它不会创建红色通知宝石——它很容易被忽视。
这是一个将为您生成请求的功能:
protected function sendFBNotification($user_id, $app_id, $app_secret, $message)
{
$token_url = 'https://graph.facebook.com/oauth/access_token?' .
'client_id=' . $app_id .
'&client_secret=' . $app_secret .
'&grant_type=client_credentials';
$app_access_token = file_get_contents($token_url);
$apprequest_url ='https://graph.facebook.com/' .
$user_id .
'/apprequests?message='.urlencode($message).
'&data=null&' .
$app_access_token . '&method=post';
try
{
$result = file_get_contents($apprequest_url);
return json_decode($result, true);
}
catch(ErrorException $e)
{
return false;
}
}
}