简体   繁体   English

从网页允许用户将图像发布到时间轴(图像托管在Facebook上)

[英]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 !!! ) 所以我想允许用户单击一个按钮,然后将图像发布到Facebook(关键是我希望它像自己上传图像一样发布到Facebook上-以便将图像托管在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). 如果我仅使用下面的链接,那么结果将在下面的红色中概述(图像仍托管在Amazon Web Services上 ,而不托管在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并发布图片,它看起来像下面的内容(黄色轮廓)-托管在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) Facebook最近不赞成使用'publish_actions'权限: https : //developers.facebook.com/blog/post/2018/04/24/new-facebook-platform-product-changes-policy-updates/ (2018年4月4日-和不再支持新应用程序的'publish_actions',并将停止对现有应用程序的旧版支持(2018年8月1日)

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. 我能够在https://developers.facebook.com/apps上创建一个Facebook应用程序,并且能够登录用户,但该用户需要权限。

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. 随着您注意到API的弃用,Facebook试图摆脱可以发布在用户墙上的应用程序。

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. 他们仍然提供的唯一写许可是针对应用程序的页面: https : //developers.facebook.com/docs/facebook-login/permissions/#reference-publish_pages-用于页面管理应用程序或发布计划程序。

Apparently posting is stuck to the sharing snippet you used above. 显然,发布停留在您上面使用的共享代码段中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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