简体   繁体   English

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

[英]How to send notifications using Azure Notification Hub with PHP?

I am trying to send the notification to my azure notification hub using PHP. 我正在尝试使用PHP将通知发送到我的azure通知中心。 I am using these 2 classes to send out the notifications. 我正在使用两个类来发送通知。 When I try to send the notifications, I see this error 当我尝试发送通知时,我看到了这个错误

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

Bad Request

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

My function is 我的功能是

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 clearly indicate that the request is malformed (for example, not valid routing headers, not valid content-type, message exceeds size, bad message format). 400清楚地表明请求格式错误(例如,无效的路由标头,无效的内容类型,消息超出大小,错误的消息格式)。

Is your hub name is "Central US"? 您的枢纽名称是“美国中部”吗? Please check this blog for reference 请查看此博客以供参考

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

See if it helps. 看看它是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM