如何使用图形api从提要中获取大图? [英] How to get the large picture from feed with graph api?
本文介绍了如何使用图形api从提要中获取大图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从一个页面加载 Facebook 提要时,如果提要中存在图片,我想显示大图.
When loading the Facebook feeds from one page, if a picture exist in the feed, I want to display the large picture.
如何使用 graph API
?提要中的图片链接不是大的.
How can I get with the graph API
? The picture link in the feed is not the large one.
谢谢.
推荐答案
这是一种获取大图像的新方法.它是在预览方法不起作用之后诞生的
This is a new method to get a big image. it was born after the previews method doesn't works
/**
* return a big url of facebook
* works onky for type PHOTO
* @param picture
* @param is a post type link
* @return url of image
*/
@Transactional
public String getBigImageByFacebookPicture(String pictrue,Boolean link){
if(link && pictrue.contains("url=http")){
String url = pictrue.substring(pictrue.indexOf("url=") + 4);
try {
url = java.net.URLDecoder.decode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
StringBuffer sb = new StringBuffer("Big image for Facebook link not found: ");
sb.append(link);
loggerTakePost.error(sb.toString());
return null;
}
return url;
}else{
try {
Document doc = Jsoup.connect(pictrue).get();
return doc.select("#fbPhotoImage").get(0).attr("src");
} catch (Exception e) {
StringBuffer sb = new StringBuffer("Big image for Facebook link not found: ");
sb.append(link);
loggerTakePost.error(sb.toString());
return null;
}
}
}
欣赏您的大图 :)
这篇关于如何使用图形api从提要中获取大图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文