通过API通知应用程序向用户发送通知 [英] Send notification to user from app via notification API
本文介绍了通过API通知应用程序向用户发送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过通知API从应用发送通知给已验证我的应用的用户。有人可以帮我吗任何帮助将不胜感激。
I want to send notification from app via notification API to a user who has authenticated my app. Can anyone help me regarding it? Any help will be appreciated.
让我们说,我希望用户在我的应用中发生某些事件时收到通知
Lets say, I want user to get a notification when certain events happens in my app
提前感谢
推荐答案
我自己找到了解决方案。开发人员需要遵循以下步骤:
I found its solution myself. Developer need to follow following steps:
代码:
require_once "facebook-php-sdk/facebook.php";
$facebook = new Facebook();
$app_id = YOUR_APP_ID;
$app_secret = YOUR_APP_SECRET;
$app_access_token = $app_id . '|' . $app_secret;
$response = $facebook->api( '/RECEIVER_USER_ID/notifications', 'POST', array(
'template' => 'You have received a new message.',
'href' => 'RELATIVE URL',
'access_token' => $app_access_token
) );
print_r($response);
如果一切正常,您将获得以下输出:
if everything works fine then you will get following output:
Array
(
[success] => 1
)
这篇关于通过API通知应用程序向用户发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文