开发者

How to share content with multiple friends on Facebook?

I am building a feature that will allow users to post to multiple friends' walls on Facebook. I'm using an FBML multi-friend input to开发者_如何学C let users select an arbitrary number of friends with whom to share.

I know how to use the API to post to multiple Facebook walls, but I need the IDs of the users in the multi-friend input. The problem is that the input is in a Facebook iFrame, so I can't just read off the ids with javascript.

Does anyone know how to work around this?


Though this isn't really answering the question, If you have the time I would consider using the new Graph API:

http://developers.facebook.com/docs/api

You can easily get all your friends / or a specified users friends and post to their walls with just a couple of API calls.

FB's new API makes doing things SO much easier. There are also various SDKs to help make your life easier. (PHP SDK: http://github.com/facebook/php-sdk/ <- my favorite)


first : making apps in FBML is a really big mistake cause there is no more support for that . you can use other better ways to select friends like creating a friend selector your self easily

P.S:i think you shouldn't post a same content on multiple friends wall (maybe that was about links - not sure)


Try this code to find the friend's ID from the Facebook https://github.com/mbrevoort/jquery-facebook-multi-friend-selector

And this is for the example to send the friends wall.

<html>
<body>
<script type="text/javascript" src="jquery.min.js"></script>
<script>
      FB.init({appId: "XXXXXXXXXXXXXXXX", status: true, cookie: true});
        function friendWallPublish() {
            var receivers = $("#friends").val();    
            var temp = new Array();

            temp = receivers.split(',');

            var count =temp.length;

            for (var i = 0; i < count; i++) {

                 var publish = {

                     method: 'stream.publish',
                     message: 'test',
                     picture : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/img/logo.gif',
                     link : 'http://www.test.com',
                     name: 'test',
                     caption: 'Caption of the Post',
                     description: 'testttttt',
                     actions : { name : 'testing', link : 'http://www.takwing.idv.hk/tech/fb_dev/index.php'}
                   };

                FB.api('/'+temp[i]+'/feed', 'post',publish, function(response) {
                  if (!response || response.error) {
                    alert('Error occured');
                  } else {
                    alert('success publishing: ' );
                  }
                });


            }
        }
</script>
<input type="hidden" value="100001496800356, 1834782228" name="friends" id="friends">
<input type="submit" class="send" onclick="friendWallPublish(); return false;" value=""/>       
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜