monotouch-facebook
monotouch-facebook copied to clipboard
Need example of posting a link to the wall
I managed to integrate the library with my app but I saw that the publish-button code has not been translated to .net. Not the easiest of code so would be great to have a .net example of posting a link to the users wall.
PublishButton.TouchDown += delegate {
// SBJSON jsonWriter = [[SBJSON new] autorelease];
//
// NSDictionary actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
// @"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
//
// NSString actionLinksStr = [jsonWriter stringWithObject:actionLinks];
// NSDictionary attachment = [NSDictionary dictionaryWithObjectsAndKeys:
// @"a long run", @"name",
// @"The Facebook Running app", @"caption",
// @"it is fun", @"description",
// @"http://itsti.me/", @"href", nil];
// NSString attachmentStr = [jsonWriter stringWithObject:attachment];
// NSMutableDictionary params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// kAppId, @"api_key",
// @"Share on Facebook", @"user_message_prompt",
// actionLinksStr, @"action_links",
// attachmentStr, @"attachment",
// nil];
//
//
// [_facebook dialog: @"stream.publish"
// andParams: params
// andDelegate:self];
};
cnordvik, here's a short (and partial) example:
Facebook fb = new Facebook(kMyAppId);
NSMutableDictionary parms = new NSMutableDictionary ();
parms.Add ("message", "this is the default message");
String videoImg = "http://img.youtube.com/vi/r3zlp3Ok7F8/default.jpg";
String videoLink = "http://www.youtube.com/watch?v=r3zlp3Ok7F8";
String videoSource = "http://www.youtube.com/v/r3zlp3Ok7F8";
parms.Add("picture", videoImg);
parms.Add("link", videoLink);
parms.Add ("source", videoSource);
parms.Add ("name", "this is a name");
parms.Add ("caption", "this is a caption");
parms.Add ("description", "this is a description");
fb.Dialog ("feed", parms, this);
Note this assumes that "this" already extends FBDialogDelegate. It also makes use of the following extension method, so you don't have to create a lot of NSStrings by hand:
public static void Add (this NSMutableDictionary dict, String key, String val)
{
dict.Add (new NSString (key), new NSString (val));
}