我希望能够在 Azure 事件目录中获取所有用户的 office365 照片。
现在我可以使用 graph SDK 获取当前用户的电子邮件
GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();
public async Task<string> GetMyEmailAddress(GraphServiceClient graphClient)
{
User me = await graphClient.Me.Request().Select("mail,userPrincipalName").GetAsync();
return me.Mail ?? me.UserPrincipalName;
}
但我不确定如何集成 the getting photos part来自 https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/profilephoto_get进入代码。
感谢任何帮助或代码示例!!
最佳答案
这有助于获取图像
GraphServiceClient graphServiceClient = GetAuthenticatedGraphServiceClient();
Stream photo = await graphServiceClient.Me.Photo.Content.Request().GetAsync();
if (photo != null)
{
MemoryStream ms = new MemoryStream();
photo.CopyTo(ms);
byte[] buffer = ms.ToArray();
string result = Convert.ToBase64String(buffer);
string imgDataURL = string.Format("data:image/png;base64,{0}", result);
ViewBag.ImageData = imgDataURL;
}
else
{
ViewBag.ImageData = "";
}
关于c# 如何使用 Microsoft Graph API 获取 Office 365 用户照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42126660/