如何连接到Exchange 2013 EWS才能获得照片? 我需要什么库(API)以及如何嵌入它? (我是php的初学者)
这是我现在的代码:
https://exchange.domen.local/ews/exchange.asmx/s/GetUserPhoto?email=mail@mail.ru&size=HR240x240
他问我登录/密码。非常好。但我需要一种方法将登录名/密码写入脚本。感谢。
答案 0 :(得分:1)
以下是我使用curl在PHP中处理此问题的方法。它很简单,没有卷曲之外的依赖。
针对Exchange 2013服务器进行了测试。直接保存到文件。
$server = ''; // owa.whatever.com, etc.
$user = ''; // username without domain info
$password = '';
$email_to_get = ''; // Email to pull photo
$fullurl = "https://$server/ews/Exchange.asmx/s/GetUserPhoto?email=$email_to_get&size=HR648x648"; //sizes defined at https://msdn.microsoft.com/en-us/library/jj194329(v=exchg.80).aspx
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullurl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM | CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$password");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$returned = curl_exec($ch);
$fp = fopen("pic.jpg", 'w'); // Save picture locally to .jpg
fwrite($fp, $returned);
fclose($fp);
header('Content-type: image/jpeg');
echo $returned; // Display the image on the page if desired
答案 1 :(得分:0)