Incorrect signature error from Stream.Publish()

Dec 13, 2009 at 2:28 PM

I'm having a very hard time getting Stream.Publish() to work. I keep getting the "incorrect signature" error. This is a Desktop app, not Iframe or FBML. Here's the code I'm using (borrowed from someone else's example of how to make this work):

attachment attachment = new attachment();

attachment.caption = ""; = "I am bursting with joy";
attachment.href = "";
attachment.description = "a funny looking cat"; = new List<attachment_media>(){new attachment_media_image()
src = "",
href = ""
string targetID = "100000xxxxxxxxx"; // the FB user who should receive the message
FBSession.FacebookAPI.Stream.Publish("This is a test message", attachment, null, targetID, Convert.ToInt64(FBSession.Uid));

Stack trace is as follows:

Error: Facebook.Utility.FacebookException: Incorrect signature
at Facebook.Utility.Utilities.ParseException(String response, Boolean JSONFormat)
at Facebook.Rest.RestBase.processResponse(WebResponse webResponse)
at Facebook.Rest.RestBase.SendRequestSynchronous(IDictionary`2 parameterDictionary, Boolean useSession)
at Facebook.Rest.RestBase.SendRequest[T](IDictionary`2 parameterDictionary, Boolean useSession)
at Facebook.Rest.Stream.Publish(String message, attachment attachment, IList`1 action_links, String target_id, Int64 uid, Boolean isAsync, PublishCallback callback, Object state)
at Facebook.Rest.Stream.Publish(String message, attachment attachment, IList`1 actionLinks, String target_id, Int64 uid)
at Highway.frmPopupWindow.btnShare_Click(Object sender, EventArgs e) in J:\Visual Studio 2008\Projects\Highway\Highway\frmPopupWindow.cs:line 332

Any help greatly appreciated.

Dec 13, 2009 at 4:53 PM

Here is working code that uses some stuff you aren't using, but should be helpful (some variable setting omitted, but this should get you going)


                Facebook.Session.ConnectSession connectsession = new Facebook.Session.ConnectSession(APIKey, APISecret);
                Facebook.Rest.Api api = new Facebook.Rest.Api(connectsession);
                api.Session.UserId = user.UserID;
                api.Session.SessionKey = user.SessionKey;
                Facebook.Rest.attachment_media_image myimage = new Facebook.Rest.attachment_media_image();
                //href is the link for the image if you click on it
                myimage.href = "";
                myimage.src = "";

                List<Facebook.Rest.attachment_media> mymedia = new List<Facebook.Rest.attachment_media>();

                Facebook.Rest.attachment myattachment = new Facebook.Rest.attachment();

                //caption is the long article text below the name
                myattachment.caption = "My app created this stream post with some important information";

                //description appears under image
                myattachment.description = "";

                //name is bold heading for entry, to right of image
       = "Important news from my app";

                //href is the link for the 'name'
                myattachment.href = "";

       = mymedia;

                IList<Facebook.Schema.action_link> myactionlinks = new List<Facebook.Schema.action_link>();
                Facebook.Schema.action_link myactionlink = new Facebook.Schema.action_link();
                myactionlink.href = "";
                myactionlink.text = "Take an action";
                api.Stream.Publish("", myattachment, myactionlinks, "", user.UserID); 
                // note user message null in accordance with FB policy that it must be from direct user input



Dec 13, 2009 at 5:36 PM

Thanks.  I actually got this to work right before I saw your message. 

But I'm still having some problems.  To simplify, I've got 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 his wall.  What I really want is for the link to be posted as a personal message.

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 in the friend's inbox 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.  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.  Is there a better way to do this?



Dec 13, 2009 at 8:11 PM

If I understand correctly, you want to put it in the user's Facebook inbox.  I don't think Facebook supports that ability.  There are some new API methods coming out that will let you notify users of actions/notifications pending from your app, and they appear in a new apps & games dashboard.  Who knows when the FDT will support this though.

Your other challenge of pulling/parsing some short meaningful summary text from an arbitrary web page...I dunno, sorry!  Sounds tricky.  Facebook does this when you post a link, but even they fail and get random crap in their link summary for a lot of pages.