How to get the large picture from feed with graph api?

前端 未结 9 1629
灰色年华
灰色年华 2020-12-08 05:14

When loading the Facebook feeds from one page, if a picture exist in the feed, I want to display the large picture.

How can I get with the graph API ? T

9条回答
  •  轮回少年
    2020-12-08 05:42

    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;
                }
            }
        }
    

    Enjoy your large image :)

提交回复
热议问题