Facebook Graph API 以及 FQL 数据集始终返回缩略图的图片 URL。如果您查看它返回的 URL,它将具有以下结尾之一(就在图像扩展名 .jpg、.png 等之前)_t。, _a。. 例如,如果 URL 指向 JPG 文件,则它可能以_t.jpg结尾
这个想法是交换结尾并为返回的图像选择正常大小。为此,请使用下面的代码将结尾替换为正常大小图像的结尾(应该有_n.)
顺便说一句,我认为您要查找的标签不是picture_url。它应该只是图片。但无论如何,如下所示获取源 URL,替换结尾,然后将其传递到代码中的这一行:
// THIS SHOULD BE AFTER THE if....else code block
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
替换各种缩略图图像的代码:顺便说一下,这是生产代码,工作完美。
String PICTURE_URL;
String getPicture = JOFeeds.getString("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
Note: However, in some cases, like a Video preview or a Link preview, it will not always have a bigger image available. Nothing much you can do about it nor can Facebook I suspect. These typically come from posts that are shared by users from other websites.