通过通知 API 从应用程序向用户发送通知 [英] Send notification to user from app via notification API

查看:27
本文介绍了通过通知 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:

  1. https://developers.facebook.com/docs/reference/php/
  2. 运行以下代码段:

代码:

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);

如果一切正常,您将得到以下输出:

Array

(

    [success] => 1
)

这篇关于通过通知 API 从应用程序向用户发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆