Office365 OAuth缺少此服务此服务的身份验证需要OAuth
为什么我们不再能够查询office365 REST URL来获取消息 上周,我可以通过访问URL来阅读邮件: 现在我只能得到这样的回答:Office365 OAuth缺少此服务此服务的身份验证需要OAuth,office365,Office365,为什么我们不再能够查询office365 REST URL来获取消息 上周,我可以通过访问URL来阅读邮件: 现在我只能得到这样的回答: {"error":{"code":"OAuthMissingForThisService","message":"Authentication for this service requires OAuth: outlook.office.com."}} 谢谢,不支持基本身份验证,因为OAuth是推荐的身份验证机制,但是如果需要继续使用基本身份验证,您可以继
{"error":{"code":"OAuthMissingForThisService","message":"Authentication for this service requires OAuth: outlook.office.com."}}
谢谢,不支持基本身份验证,因为OAuth是推荐的身份验证机制,但是如果需要继续使用基本身份验证,您可以继续使用。很抱歉,我无法编辑我的问题以添加我向Thomas承诺的示例,现在就是了 (请参阅更多参考资料:) `
`Merci Venkat!:)你救了我一天!你也救了我一天:)你救了我一天,这可能是我在Stackoverflow上见过的最好的技巧之一。谢谢
//GET method for REST API
function ews_get($odata_command)
{
//$URL = 'https://outlook.office.com/api/v1.0/Me'; //doesn't work anymore
$URL = 'https://outlook.office365.com/api/v1.0/Me'; //Thanks Venkat :)
//concatenation of the command url
$URL .= $odata_command;
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page content
CURLOPT_FOLLOWLOCATION => true, // follow redirections
CURLOPT_AUTOREFERER => true, // set referer on redirections
CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
CURLOPT_TIMEOUT => 60, // timeout on response
CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks
CURLOPT_USERPWD => EWS_USERNAME . ':' . EWS_PASSWORD, //see constants
CURLOPT_HTTPAUTH => CURLAUTH_BASIC, //Basic authentication
);
$ch = curl_init($URL);
curl_setopt_array( $ch, $options );
$objResult = json_decode(curl_exec( $ch ));
curl_close( $ch );
return $objResult;
}
//Return a folder information for an Inbox subfolder named $displayName
function getInboxChildFolderByDisplayName($displayName)
{
//NOTE DEV: The $ sign is not correctly interpreted in a double quote string in php
//NOTE DEV: The ' in the url was replaced by %27
$results = ews_get('/Folders(\'Inbox\')/ChildFolders?$filter=DisplayName%20eq%20%27' . $displayName . '%27');
$arrFolderInfo = $results->value;
//return the first folder info
return $arrFolderInfo[0];
}
//Get messages from the folder id
function getMessagesFromFolderId($folderId = 'Inbox')
{
$objResult = ews_get("/Folders('" . $folderId . "')/Messages");
return $objResult->value;
}
/////////////
//Example
/////////////
$folder_id = getInboxChildFolderByDisplayName('MySubFolder')->Id;
$arrMessage = getMessagesFromFolderId($folder_id);
print_r($arrMessage);
//Have fun!
?>