【问题标题】:How to send notifications using Azure Notification Hub with PHP?如何使用带有 PHP 的 Azure 通知中心发送通知?
【发布时间】:2019-04-07 08:11:37
【问题描述】:

我正在尝试使用 PHP 将通知发送到我的天蓝色通知中心。我正在使用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 清楚地表明请求格式错误(例如,无效的路由标头、无效的内容类型、消息超出大小、错误的消息格式)。您的中心名称是“美国中部”吗?请查看此博客以获取参考docs.microsoft.com/en-us/azure/notification-hubs/…
  • 这是一个愚蠢的错误。将集线器名称更改为我的实际名称,现在一切正常。谢谢
  • 很高兴知道它有效,我想请你接受这个作为答案,这样可以帮助所有有相同 ASK 的人。

标签: php azure push-notification azure-eventhub


【解决方案1】:

400 清楚地表明请求格式不正确(例如,无效的路由标头、无效的内容类型、消息超出大小、错误的消息格式)。

您的中心名称是“美国中部”吗?请查看此博客以供参考

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

看看有没有帮助。

【讨论】:

    猜你喜欢
    • 2016-07-31
    • 1970-01-01
    • 2021-04-18
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    相关资源
    最近更新 更多