我正在尝试订阅Outlook Mail API中的通知。 但是我一直收到400错误。 参考: msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations
$url = 'outlook.office.com/api/v2.0/me/subscriptions';
$headers = array(
"Authorization: Bearer ".$access_token ,
"Accept: application/json",
"X-AnchorMailbox: ".$user_email
);
$curl = curl_init($url);
$data = '{
"@odata.type":"#Microsoft.OutlookServices.PushSubscription",
"Resource": "outlook.office.com/api/v2.0/me/messages",
"NotificationURL": "mydomain.com/listener.php",
"ChangeType": "Created"
}';
$headers[] = "Content-Type: application/json";
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
$response = curl_exec($curl);
我还没有设置我的听众。因听众而导致400错误吗?或者是别的什么?。似乎认证成功
答案 0 :(得分:0)
此订阅请求存在两个问题 1- Outlook / Office365通知需要安全通道;即NotificationURL必须是'https'。这可能是您400错误的原因。 2- NotificationURL必须启动并运行,因为服务在接受订阅之前会执行此URL的验证。
请提供文档https://msdn.microsoft.com/office/office365/APi/notify-rest-operations或入门概念https://dev.outlook.com/RestGettingStarted/Concepts/Webhooks以获取更多信息。
感谢。