如何通过 php 连接到 exchange 2013 EWS(仅获取照片)
How to connect to the exchange 2013 EWS via php (just get photo)
如何连接到exchange 2013 EWS just get photo?
我需要什么库 (API) 以及如何嵌入它? (我是 php 的初学者)
这是我现在的代码:
https://exchange.domen.local/ews/exchange.asmx/s/GetUserPhoto?email=mail@mail.ru&size=HR240x240
他问我login/password。那挺好的。但我需要一种将 Login/password 写入脚本的方法。谢谢
您提供的 "Code" 不完整。您仅触发 URL 但未指定您希望从 xml 流中获取图片。
最好的方法是查看 Microsoft HowTo here, it provides examples you could adjust to your needs. If you are unable to do that you might wish to check the PHP EWS library from here。
以下是我在 PHP 中使用 curl 处理此问题的方法。它很简单,没有 curl 之外的依赖项。
已针对 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
如何连接到exchange 2013 EWS just get photo? 我需要什么库 (API) 以及如何嵌入它? (我是 php 的初学者)
这是我现在的代码:
https://exchange.domen.local/ews/exchange.asmx/s/GetUserPhoto?email=mail@mail.ru&size=HR240x240
他问我login/password。那挺好的。但我需要一种将 Login/password 写入脚本的方法。谢谢
您提供的 "Code" 不完整。您仅触发 URL 但未指定您希望从 xml 流中获取图片。
最好的方法是查看 Microsoft HowTo here, it provides examples you could adjust to your needs. If you are unable to do that you might wish to check the PHP EWS library from here。
以下是我在 PHP 中使用 curl 处理此问题的方法。它很简单,没有 curl 之外的依赖项。
已针对 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