Sending a link as a personal message? Stream.publish or something else?

Dec 13, 2009 at 6:44 PM


I'm writing an application that has a webbrowser control and a button.  When the user clicks the button, I want them to be able to send a link to the page currently displayed in the web browser control to one or more of their friends.  I'm already getting the friends list and I know how to work the webbrowser control.  The problems I'm having are with the way stream.publish() works.  Here's what I mean:

1) If I specify a user id for the target_id parameter, it gets posted to the friend's wall.  What I really want is for the link to be posted as a personal message.  (And I don't want to use the feed object because it's about to be done away with by facebook.)  How can this be done?

2) I was hoping that I'd be able to pass the url of the page in question as one of the parameters and have the link appear formatted the way you see it if a user sends a link from within Facebook.  Apparently the stream.publish method doesn't work that way, because it requires me to manually assign the attachment.description property, etc, nor does it automatically recognize any images in the page.  I tried assigning the first 200 characters of the web page to the attachment.description property as a summary, but that causes html code to be passed in.  Next I tried passing the first 200 characters of the documents body.innerText property, but that causes all the navigation menus on the page to be included which I don't want obviously.  I suppose I could traverse the dom to get me a list of images easily enough, but as far as the description/summary goes, I really don't want to have to parse the whole page and try to figure out what content actually should go in the description.  Is there a better way to do all of this?



Dec 13, 2009 at 6:45 PM

By the way, this is a desktop application, not web.

Jan 6, 2010 at 3:18 AM

Can you please send me the code to post to a friends wall? I can only post to my own wall, sorry I can't help you.

Jan 12, 2010 at 7:43 AM
Edited Jan 12, 2010 at 7:44 AM

<script type="text/javascript">        
        function publishToWall(description) {
            var attachment = {
                'name': 'Gilldivers',
                'href': '',
                'description': description,
                'media': [
                            'type': 'image',
                            'src': '',
                            'href': ''
            var actionLinks = [
                    "text": "Play Now!",
                    "href": ""

           var friendIds = "21312,2312321,12312312";

            Facebook.streamPublish('', attachment, actionLinks, friendIds, "What's on your mind?", function(post_id, exception) { });

Jan 13, 2010 at 2:00 AM

Thanks, but not getting it to work. Are there any Javascript files you need to include in the site <head/>?

Jan 13, 2010 at 2:45 AM

Check out this thread: