简体   繁体   中英

From Web Page allow user to post Image to Timeline (with Image hosted on Facebook)

So I am wanting to allow users to click a button and it posts an image to facebook ( The Key though is I want it to post to facebook the same as if they uploaded the image them self -- So that the Image is Hosted on Facebook !!! )

If I just use the below link, then I get the result outlined in Red below (image still hosted on Amazon Web Services -- not hosted on Facebook).

<a href="https://www.facebook.com/sharer/sharer.php?u=https://s3.amazonaws.com/naf-socialforyou/images/pie_graph.PNG" target="_blank" class="btn btn-share">POST TO FACEBOOK</a>

If I go to Facebook and post the image, it looks like the below (Outlined in Yellow) -- hosted on Facebook!!!

Facebook just recently deprecated 'publish_actions' permissions: https://developers.facebook.com/blog/post/2018/04/24/new-facebook-platform-product-changes-policy-updates/ (April 4th, 2018 - and no longer supports 'publish_actions' for new apps, and will stop legacy support for existing apps August 1st, 2018)

I was able to make a Facebook app on https://developers.facebook.com/apps and I was able to login a user but the user would need permissions.

When I run the code to post an image (after the user is logged in):

filename = "https://s3.amazonaws.com/naf-socialforyou/images/pie_graph.PNG";
    encodedname = encodeURI(filename);
FB.api('/photos', 'post', {
        message: 'photo description goes here',
        url: encodedname
    }, function (response) {

        if (!response || response.error) {
            console.error(response);
        } else {
            console.log('Post ID: ' + response.id);
        }

    });

Then I get error: 在此处输入图片说明

With the API deprecation that you noticed, Facebook is trying to move away from apps that can post on a users wall.

The only write permission that they still offer is for apps to pages: https://developers.facebook.com/docs/facebook-login/permissions/#reference-publish_pages - useful for page managing apps or posts schedulers.

Apparently posting is stuck to the sharing snippet you used above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM