我正在尝试查询Graph API,以使用“参与者”搜索词向我返回从OR到特定电子邮件地址的邮件。
文档在这里;https://docs.microsoft.com/zh-cn/graph/query-parameters
代码示例(有效):
$encoded_addresses = urlencode("participants:[email protected]");
$url = 'https://graph.microsoft.com/v1.0/me/messages?$search="' . $encoded_addresses . '"';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Prefer: outlook.body-content-type="text"', 'Accept: application/json','Authorization: Bearer '.$account['access_token']));
$response = curl_exec($ch);
print_r($response);
一个电子邮件地址(上面的示例)有效。但是,如果我将多个电子邮件地址传递给参与者参数,它将失败,并且无论参与者如何,我都将检索到邮箱中的所有消息。
代码示例(不起作用):
$encoded_addresses = urlencode("participants:[email protected] or [email protected]");
$url = 'https://graph.microsoft.com/v1.0/me/messages?$search="' . $encoded_addresses . '"';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Prefer: outlook.body-content-type="text"', 'Accept: application/json','Authorization: Bearer '.$account['access_token']));
$response = curl_exec($ch);
print_r($response);
我正在使用PHP和cURL。
是否有人设法搜索多个值?如果是的话,用什么语法?
注意我正在使用搜索而不是过滤器参数。
谢谢
正如您在评论中提到的那样,您的请求网址是这样的:
https://graph.microsoft.com/v1.0/me/messages?$search="participants:[email protected]" or "participants:[email protected]"
错了 正确的表格应为:
https://graph.microsoft.com/v1.0/me/messages?$search="participants:[email protected] or participants:[email protected]"
https://graph.microsoft.com/v1.0/me/messages?$search="participants:[email protected] or [email protected]"
尝试使用curl_escape
代替urlencode
$ch = curl_init();
$query = curl_escape($curl ,'participants:[email protected] or [email protected]');
$url = 'https://graph.microsoft.com/v1.0/me/messages?$search="' . $query . '"';
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句