2014-03-14 78 views
-1

我需要在我的Facebook应用程序中使用图像URL发布图像可能吗? 如何在点击按钮后将图像发布到Facebook? 在可变图像,由可变shareUrl facebook的URL我已存储IMAGEURL,使用应用程序ID将图像发送到Facebook应用程序

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> 

回答

0
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。希望可以帮助

相关问题