Stream.publish

Jul 23, 2009 at 5:40 PM
Edited Jul 23, 2009 at 5:40 PM

For some reason, when using stream.publish, it publishes as a status update not a wall post.  This is the code I am using - 

                    Dictionary<string, string> param = new Dictionary<string, string>();

                    param.Add("method", "Stream.publish");
                    param.Add("message", "Test message");

                    base.API.SendRequest(param);

What other paramaters does this accept and how would I add them to make it work correctly? 

Developer
Jul 28, 2009 at 3:31 PM

From what I understand, if you don't want an update to publish as a status update, you have to pass in an "attachment" parameter as well. See this page for details: http://wiki.developers.facebook.com/index.php/Stream.publish

That said, I don't really know these days if Facebook treats normal wall updates much differently from status updates, since they're very similar. Also, you might want to get the latest version of the FDT - it should have stream.publish already implemented for you, so you don't have to write the whole thing yourself.

Jul 28, 2009 at 4:05 PM

I cant find how to use stream.publish in the latest version.  Any help?

Jul 28, 2009 at 6:27 PM

Well I found it... But when trying to add an attachment, I get an object reference not set to instance of an object.  Any ideas -

facebook.Components.FacebookService fbService = new facebook.Components.FacebookService();
            fbService.API.ApplicationKey = "APPKEY";
            fbService.API.Secret = "SECRET";
            attachment thisAttachment = new attachment();
            thisAttachment.name = "Attachment Name";
            thisAttachment.caption = "Attachment Caption";
            thisAttachment.href = http://apps.facebook.com/myapp;
            thisAttachment.description = "Attachment description";
            fbService.API.stream.publish("This is a test message", thisAttachment, null, base.API.uid.ToString(), Convert.ToInt32(base.API.uid));

 

Developer
Jul 28, 2009 at 7:27 PM

I assume you're using version 2.1 of the toolkit? That version has a bug in it which has been fixed in 3.0, where the "properties" of the attachment were required instead of optional. You have a few options: populate the "properties" property as needed, edit the toolkit code for 2.1 locally to fix the bug, or upgrade to 3.0 (source only available right now - official binary release coming soon).

Jul 29, 2009 at 2:44 PM

I tried with the 3.0 code and it said facebook.Components doesn't exist.  What is the exact markup I need to use to add properties?  All the intellisense says is attachment_property attachment.properties and I have no idea how to form that

Jul 30, 2009 at 4:08 PM
Edited Jul 30, 2009 at 4:48 PM

Duh, for future reference for people just use -

attachment attachment = new attachment();

            attachment.caption = "www.icanhascheezburger.com";
            attachment.name = "I am bursting with joy";
            attachment.href = "http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/";
            attachment.description = "a funny looking cat";
            attachment.properties = new attachment_property()
            {
                category = new attachment_category()
                {
                    href = "http://www.icanhascheezburger.com/category/humor",
                    text = "humor"
                },
                ratings = "5 stars"
            };
            attachment.media = new List<attachment_media>(){new attachment_media_image()
                                    {
                                        src = "http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg",
                                        href = "http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/"
                                    }};

            fbService.API.stream.publish("This is a test message", attachment, null, base.API.uid.ToString(), Convert.ToInt32(base.API.uid));
Nov 1, 2010 at 3:49 PM

hi to all

i have one clarification in this above code. It has used "fbservice". i want to know "fbservice" version and download link.. 

Please help me...