如何通过 PHP 使用 Azure 通知中心发送通知?

How to send notifications using Azure Notification Hub with PHP?

我正在尝试使用 PHP 将通知发送到我的 Azure 通知中心。我正在使用 these 2 类 发送通知。 当我尝试发送通知时,我看到了这个错误

{ "message": "Error sending notificaiton: 400 msg: \r\n\r\n\r\n

Bad Request

\r\n
HTTP Error 400. The request is badly formed.

我的职能是

public function sendNotificationHub() {


        $hub    =   new \App\Helpers\NotificationHub('connection string', 'central US');
        $message = '{"data":{"message":"Hello from PHP!"}}';

        $notification   =   new \App\Helpers\Notfication("gcm", $message);

        $hub->sendNotification($notification, null);
    }

400 清楚地表明请求格式错误(例如,路由无效 headers、无效 content-type、消息超出大小、消息格式错误)。

您的中心名称是 "Central US" 吗?请查看此博客以供参考

https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-php-push-notification-tutorial

看看有没有帮助。