![](/img/trans.png)
[英]https://graph.facebook.com/v2.10/me/photos?access_token=xxxxxx returning error
[英]graph.facebook.com/me/home photos width and height
如何從/me/home
獲取照片的寬度和高度?
我嘗試
/me/home?fields=picture,width,height
但寬度和高度沒有結果。
Graph API不會根據寬度和高度返回圖像的大小。 但是,您可以使用'height'和'width'參數指定要檢索的大小,例如:
me/picture?width=70&height=90
另外,您可以使用'type'參數檢索一些默認尺寸: https : //developers.facebook.com/docs/reference/api/using-pictures/#sizes
最后,您可以檢索任何大小的圖片,並以編程方式獲取其寬度和高度。
JavaScript示例:
現代瀏覽器和IE9 +:
var width = document.getElementById('yourImg').naturalWidth,
height = document.getElementById('yourImg').naturalHeight;
console.log(width, height);
對於IE8-:
var img = new Image(), // or document.createElement('img')
width,
height;
img.onload = function() {
width = this.width;
height = this.height;
};
img.src = 'http://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/626_someid_202729_q.jpg'
console.log(width, height);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.