Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need example of posting a link to the wall #8

Open
cnordvik opened this issue Jan 26, 2011 · 1 comment
Open

Need example of posting a link to the wall #8

cnordvik opened this issue Jan 26, 2011 · 1 comment

Comments

@cnordvik
Copy link

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];
};

@ghost
Copy link

ghost commented Mar 1, 2011

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));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant