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

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

问题描述:

I am trying to send the notification to my azure notification hub using PHP. 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: 




Bad Request



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

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

See if it helps.