【问题标题】:Post a image into facebook app using app id使用应用程序 ID 将图像发布到 Facebook 应用程序
【发布时间】:2014-03-14 04:21:26
【问题描述】:

我需要在我的 Facebook 应用中使用图片网址发布图片,这可能吗? 如何在按钮单击时将图像发布到 Facebook? 我已将 imageUrl 存储在变量 image 中,并将 facebook URL 存储在变量 shareUrl 中,

following is the complete facebook URL : 
"https://www.facebook.com/dialog/feed?app_id=843228839026054&caption=example.com&display=popup&redirect_uri="+encodeURIComponent("http://www.facebook.com/")+"&name=%title%&description=%desc%&picture=%image%".

<html>
<head>
<script>

var doShare = function(title, description)
{
    if(title && description)
    {
        image="http://www.sxc.hu/assets/182945/1829445627/small-flowers-1019552-m.jpg";

        /* for readability i store the url like this, above this code u can find
          the complete facebook url. */

        shareUrl = "https://www.facebook.com/dialog/feed?";
        shareUrl += "app_id=843228839026054&caption=example.com&display=popup&";
        shareUrl += "redirect_uri="+encodeURIComponent("http://www.facebook.com/");
        shareUrl += "&name=%title%&description=%desc%&picture=%image%";

        var url = shareUrl.replace(/%title%/g, encodeURIComponent(title));
        url = url.replace(/%desc%/g, encodeURIComponent(description));
        url = url.replace(/%image%/g, encodeURIComponent(image));
        var isOpen = window.open(url);
        if(!isOpen)
        {
          console.log('Please turn off "Block pop up" setting to proceed further.');
        }
    }
};

</script>
</head>
<body>
<div id='share'>
    <input type='button' onclick ='doShare("TITLE","DESCRIPTION")'>Share</input>
</div>
</body>
</html>

【问题讨论】:

    标签: javascript facebook facebook-apps


    【解决方案1】:
    FB.ui({
                                    method: 'feed',
                                    name: "some name",
                                    link: "somelink.com",
                                    picture: urltobeshared,
                                    caption: 'some caption',
                                    description: "some descrtiption",
                                  },
                                  function(response) {
                                    if (response && response.post_id) {
                                      console.log('Thank you');
                                    }                  
                                  }
                            );
                        },
    

    文档是here。希望对您有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多