Outlook推送通知REST API-订阅错误

时间:2018-11-13 10:26:51

标签: push-notification outlook subscription

我已经使用PHP curl创建了Outlook Push Notification订阅API

但是响应只是一个没有错误的空字符串。

这是我的代码;

$url = 'https://outlook.office.com/api/v2.0/me/subscriptions';
$headers = array(
    "Content-Type: application/json",
    "Authorization: Bearer " . $accessToken
);
$curl = curl_init($url);
$data = '{
    "@odata.type":"#Microsoft.OutlookServices.PushSubscription",
    "Resource": "https://outlook.office.com/api/v2.0/me/events",
    "NotificationURL": "https://{$mydomain}/outlook-notif-subscribe/",  
    "ChangeType": "Created,Deleted,Updated"
}';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);

如此处的建议Outlook webhook notification subscription

要将“资源”:“ https://outlook.office.com/api/v2.0/me/events”更改为“资源”:“我/事件”

我也收到如下所示的错误;

{
  "error": {
    "code": "InvalidAudience",
    "message": "The audience claim value is invalid 'https://localhost:3000/index.html'.",
    "innerError": {
      "requestId": "933db80e-483b-4b71-96f2-38eb6960fbad",
      "date": "2018-11-13T09:03:51"
    }
  }
}

我已经使用了从办公室邮箱API方法获取的访问令牌

https://docs.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/office.context.mailbox#getuseridentitytokenasynccallback-usercontext

getUserIdentityTokenAsync(callback, [userContext])

我错过了什么吗?还是我做错了方向?

0 个答案:

没有答案