facebook post with image (object_attachment). Image is empty. Why?

后端 未结 1 904
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 05:00

I have to create post to facebook with image from my application.
Image stored in application.

What I do:

  1. Upload image to user photos with Req

1条回答
  •  深忆病人
    2021-01-23 05:21

    I had the same issue with facebook. In your case facebook cannot show a thumbnail of your image, but when you click on the post you can see your photo in full screen view. To correct your post you have to get details of your uploaded photo by calling graph api "/{photoId}" (https://developers.facebook.com/docs/graph-api/reference/photo) and you'll get JSON similar to:

    {
    "created_time" = "";
    from =     {
        id = 100002300000000;
        name = "User User";
    };
    height = 500;
    id = 62902XXXXX;
    images =     (
                {
            height = 500;
            source = "https://scontent-b.xx.fbcdn.net/hphotos-frc3/t1.0-9/XXXX.jpg";
            width = 500;
        },
                {
            height = 480;
            source = "https://scontent-b.xx.fbcdn.net/hphotos-frc3/t1.0-9/p480x480/XXXX.jpg";
            width = 480;
        },
                {
            height = 320;
            source = "https://scontent-b.xx.fbcdn.net/hphotos-frc3/t1.0-9/p320x320/XXXX.jpg";
            width = 320;
        },
                {
            height = 130;
            source = "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-frc3/t1.0-0/XXXX.jpg";
            width = 130;
        },
                {
            height = 225;
            source = "https://scontent-b.xx.fbcdn.net/hphotos-frc3/t1.0-9/p75x225/XXXX.jpg";
            width = 225;
        }
    );
    link = "https://www.facebook.com/photo.php?fbid=629020720517945&set=a.628961963857154.1073741825.100002300681060&type=1";
    picture = "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-frc3/t1.0-0/1029_XXX.jpg";
    source = "https://scontent-b.xx.fbcdn.net/hphotos-frc3/t1.0-9/1029_XXX.jpg";
    width = 500;
    }
    

    From the response you should take "images" array and then one of the thumbnails "source" link. This link you can add to post body with "picture" key on "/me/feed" API (https://developers.facebook.com/docs/graph-api/reference/user/feed/).

    Attention: you have to call "user_photos" permission to get photo info.

    0 讨论(0)
提交回复
热议问题