我正在使用 Microsoft Graph,需要设置一个 Webhook 来接收电子邮件和日历事件的更改。我能够让它与我的 PHP Laravel 应用程序一起工作,但现在我正在尝试订阅通知,我在验证notificationUrl指向我的公共服务器的 时遇到了问题。
用于创建 Webhook 的脚本返回以下错误:
Client error: POST https://graph.microsoft.com/v1.0/subscriptions resulted in a 400 Bad Request response:
{
"error": {
"code": "InvalidRequest",
"message": "Subscription validation request failed. Response must ex (truncated...)
Run Code Online (Sandbox Code Playgroud)
我相信被截断的部分是
订阅验证请求失败。必须对此请求响应 200 OK。
这是我创建订阅的代码:
$data = [
"changeType" => "created",
"notificationUrl" => "https://anatbanielmethod.successengine.net/office365/webhooks/events",
"resource" => "me/events",
"expirationDateTime" => "2018-12-20T18:23:45.9356913Z",
"clientState" => "secret",
];
$result = $graph->createRequest('POST', '/subscriptions')
->attachBody($data)
->execute();
Run Code Online (Sandbox Code Playgroud)
这是我的方法notificationUrl:
public function events()
{
//if validationToken exists return …Run Code Online (Sandbox Code Playgroud)