返回的數據是圖像類型的二進制數據。如果您使用JavaScript檢索用戶照片,請在XMLHttpRequest中將照片數據作爲blob類型獲取,然後從響應中檢索blob URL。供您參考:
var request = new XMLHttpRequest;
var photoUri=config.endpoints.graphApiUri + "/v1.0/me/photo/$value";
request.open("GET",photoUri);
request.setRequestHeader("Authorization","Bearer "+token);
request.responseType = "blob";
request.onload = function(){
if(request.readyState == 4 && request.status == 200){
var image = document.createElement("img");
var url = window.URL || window.webkitURL;
var blobUrl = url.createObjectURL(request.response);
image.src = blobUrl;
document.getElementById("UserShow").appendChild(image);
}
};
request.send(null);
這應該是一個數據流 - jpeg圖像。你使用什麼平臺/語言? –