2012-09-18 181 views
12

我们有一个系统将以某种方式与Office 365集成,我们希望使用用户在Office 365系统中设置的个人资料图片,而不是自己存储此图片/引用。但是,我无法从Office 365外部访问此映像(例如,通过电子邮件地址)。Office 365个人资料头像图片

换句话说,Office 365能够提供用户的个人资料图片类似的方式Gravatar

+0

什么是制度和如何将它连接到Office 365和你有什么样的身份管理您的环境?您是否完全处于云端,或者您是否拥有本地AD和ADFS? –

回答

6

您还可以使用Office365统一的API(预览)https://msdn.microsoft.com/office/office365/APi/photo-rest-operations

而且为Base64编码的图像使用。请注意自上次更新以来更改的API。

这里我的代码:

HttpClient client = new HttpClient(); 
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, 
     "https://outlook.office.com/api/beta/me/photos('96x96')/$value"); 
     request.Headers.Add("ACCEPT", "image/*"); 
     request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken); 
     HttpResponseMessage response = await client.SendAsync(request); 
     byte[] byteArray = await response.Content.ReadAsByteArrayAsync(); 

     string base64ImageRepresentation = Convert.ToBase64String(byteArray); 

     if (!response.IsSuccessStatusCode && response.StatusCode >= HttpStatusCode.BadRequest) 
     { 
      return string.Empty; 
     } 

     return base64ImageRepresentation; 
+0

哦帖子是从2012年:)但也许有人需要的信息 – sergej

相关问题