【发布时间】:2016-06-14 00:40:45
【问题描述】:
我使用了“https://github.com/jasonjoh/php-tutorial”中描述的基本示例/教程,并尝试在 getMessages() 函数中添加“$search”参数
$getMessagesParameters = array (
// Message Search Conditions
"\$search" => 'subject:"pizza"',
// Only return Subject, ReceivedDateTime, and From fields
"\$select" => "Subject,Body",
// Return at most 10 results
"\$top" => "10"
);
$getMessagesUrl = self::$outlookApiUrl."/Me/Messages?".http_build_query($getMessagesParameters);
$response = $this->makeApiCall($access_token, $user_email, "GET", $getMessagesUrl);
请求返回错误 400
想知道什么是正确的语法
我参考了以下链接
https://msdn.microsoft.com/en-us/library/cc513841%28v=office.12%29.aspx
如果有人有更好的想法来搜索邮件,请建议...
【问题讨论】:
-
你用的是哪个版本的api?是否有可能显示最终请求 url(您可以通过 fiddler 或浏览器调试器 - 网络部分获取它)?
-
@BenoitPatra 我们不能使用浏览器调试器来捕获 url...请求是从服务器发出的...无论如何您都可以理解...代码使用
http_build_query()和$outlookApiUrl="https://outlook.office.com/api/v2.0"。结果 url 看起来类似于https://outlook.office.com/api/v2.0/Me/Messages?$search=subject:"pizza"&$select=Subject,Body&$orderby=ReceivedDateTime DESC&$top=10并且特殊字符可能是 url 编码的......关键是当我删除$search参数时,没有返回错误
标签: php rest oauth-2.0 outlook-restapi