PublishAction

Oct 25, 2007 at 8:52 PM
Hi,

Im trying to publish an action from a desktop app. I am using code I found on the forum but VS complains

"Argument '3': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Uri>' to 'System.Collections.ObjectModel.Collection<Facebook.Entity.PublishImage>'"

Any ideas greatly appreciated.

System.Collections.Generic.Dictionary<string, Uri> images = new Dictionary<string, Uri>();

images.Add("image_1", new Uri("http://www.myserver.png"));
images.Add("image1link", new Uri("http://www.myserver.com"));

facebookService1.PublishAction("My App", "What Im doing", images);
Developer
Oct 25, 2007 at 9:20 PM
I'm not sure where you found that code, but it definitely won't work with the toolkit as is. PublishAction takes a Collection of PublishImage objects as a parameter for the images, not a Dictionary. I don't know of any way that that would be converted automatically, either. Maybe the code you saw used an older version of the toolkit, or maybe that developer had some other code to go along with it to support it.

Try this instead:

using System.Collections.ObjectModel;
Collection<PublishImage> images = new Collection<PublishImage>();
images.Add(new PublishImage("http://www.myserver.com/picture.png", "http://www.myserver.com"));
facebookService1.PublishAction("My App", "What Im doing", images);

I assume by "www.myserver.png" you mean "www.myserver.com/picture.png", or something like that.
Oct 26, 2007 at 11:08 AM
Jon, thanks for the response. I had originally got the code sample from this thread posted back in the summer...

http://www.codeplex.com/FacebookToolkit/Thread/View.aspx?ThreadId=14344

The project now compiles fine with the code sample you have provided, and runs, thank you. But it still doesn't seem to publish anything? Ive tried both publish story and publish action. I'm pointing to a 16X16 pixel png image, first on my server, and then when that didn't work a gif on the facebook servers, but no luck. I am assuming this should add an item to my new feed? Or in the list of notifications I access from my facebook inbox?

I'm not sure what else I can really try, anyhow thanks.
Developer
Oct 26, 2007 at 3:01 PM
The method should add an item to the mini-feed shown in the profile of the logged-in user. However, note that for the to display, the user must have set the permission which allows the app to publish these items to their feed. I don't remember off-hand where you set that permission, but I think it might be when the user decides to add the application to their profile, or something like that.

To check if that's your problem, check the return value of the method. If it's 0, then that's a permission error, if it's 1, then it succeeded, and if it's anything else, that's a different error. I know that it returns a string, but the string is always (I'm pretty sure...) a number.