PHP中针对单个用户的Azure通知 [英] Azure Notifications in PHP to single Users

查看:40
本文介绍了PHP中针对单个用户的Azure通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP从Azure发送推式通知给单个用户.我已经对在我的云中注册的所有用户"进行了此操作,但是我找不到在PHP中可以将IT推到极高水平的代码(在PHP中).

I want to send Push Notifications from Azure using PHP to a single user. I'm already doing it to "All Users" registered in my cloud but I cant find the code (in PHP) that allow me to Push IT to one in espesific.

这是我用来发送给多个用户的(简单)代码,我想可能是类似的东西:

This is the (simple) code that I use to send to multiple Users, I guess it could be something similar:

include "NotificationHub.php";
$connection = "Endpoint=sb:......";
$hub = new NotificationHub($connection, "appetito24hub");
$notification = new Notification("apple", '{"aps":{"alert":{"title":"Estado de la orden", "body":"Tu orden ha cambiado del estado Aceptada a Procesada"}, "id":"4500", "type":"promo"}}');
$hub->sendNotification($notification);

有什么想法吗?谢谢!

推荐答案

最后,在检查了Microsoft Azure通知的荒谬不完整的文档后,我意识到了(阅读

In the end, and after checking the absurdly incomplete documentation of Microsoft Azure Notifications, I realize (after reading this article) that you can add the "ServiceBusNotification-Tags" to the header so the notification can be sent to THAT espesific ID.

真正的变化是在NotificationHup.php中(如果您下载了

The real change was in the NotificationHup.php (if you downloaded the Sample Code Provided by Azure Team) from this:

        $headers = [
        'Authorization: '.$token,
        'Content-Type: '.$contentType,
        'ServiceBusNotification-Format: '.$notification->format
        ];

    $headers = [
        'Authorization: '.$token,
        'Content-Type: '.$contentType,
        'ServiceBusNotification-Tags: '.$userTag,
        'ServiceBusNotification-Format: '.$notification->format
    ];

在那之后,一切工作都非常完美.

After that, everything worked just perfect.

这篇关于PHP中针对单个用户的Azure通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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