2016-01-04 50 views
0

我試圖從Outlook郵件API訂閱通知。 但是我不斷收到400錯誤。 編號: msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations通知訂閱錯誤 - Outlook郵件API

$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

沒有與此訂閱請求兩個問題 1-展望/ Office365通知要求安全通道;即NotificationURL必須是'https'。這可能是你400錯誤的原因。 2-NotificationURL必須啓動並運行,因爲服務在接受訂閱之前執行此URL的驗證。

請文檔https://msdn.microsoft.com/office/office365/APi/notify-rest-operations或入門概念https://dev.outlook.com/RestGettingStarted/Concepts/Webhooks以獲取更多信息。

謝謝。

+0

謝謝。這是由於https。 – singularity