簡體   English   中英

FACEBOOK JS SDK ::如何在牆上發布圖像

[英]FACEBOOK JS SDK ::how to post an image on wall

我試圖將圖像發布到我的用戶的Facebook牆上,一旦他們碰到了按鈕

我正在使用JavaScript SDK,但我有一個問題,圖像看起來像牆上的鏈接...但這不是我想要的...我想發布圖像...與你放一個圖像鏈接相同在您的狀態文本字段上,它將變為圖像

任何幫助?

FB.ui(
           {
             method: 'stream.publish',
             message: 'test',
             attachment :{ 
                    'name': 'i\'m bursting with joy', 
                    'href': ' http://bit.ly/187gO1', 
                    'caption': '{*actor*} rated the lolcat 5 stars', 
                    'description': 'a funny looking cat', 
                    'properties': { 
                        'category': { 'text': 'humor', 'href': 'http://bit.ly/KYbaN'}, 
                        'ratings': '5 stars' 
                    }, 
                    'media': [{ 
                            'type': 'image', 
                            'src': 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg', 
                            'href': 'http://bit.ly/187gO1'}] 
                        },
             user_message_prompt: 'Share your thoughts about Connect'
           },
           function(response) {
             if (response && response.post_id) {
               alert('Post was published.');
             } else {
               alert('Post was not published.');
             }
           }

試試FB.api()方法:

var wallPost = {
    message : "testing...",
    picture: "http://url/to/pic.jpg"
};
FB.api('/me/feed', 'post', wallPost , function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response);
  }
});

您可以在此處獲取支持的牆郵政索引列表(請參閱“發布”)。

要在用戶牆上發布圖像,請使用FB.api('/ me / photos',...)而不是FB.api('/ me / feed',...),此外還需要訪問令牌。

附件是代碼示例:

FB.login(function(response) {
    if (response.authResponse) {
        var access_token =   FB.getAuthResponse()['accessToken'];
        FB.api('/me/photos?access_token='+access_token, 'post', { url: IMAGE_SRC, access_token: access_token }, function(response) {
            if (!response || response.error) {
                //alert('Error occured: ' + JSON.stringify(response.error));
            } else {
                //alert('Post ID: ' + response);
            }
        });
    } else {
        //console.log('User cancelled login or did not fully authorize.');
    }
}, {scope: 'publish_stream'});

在朋友頁面上發帖:輸入朋友的facebook用戶ID代替“/ me”。

"/"+friends_user_id+"/photos" ....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM