Search code examples
iosfacebooksharingsharekit

Posting an image, url link, text to facebook using Sharekit 2.0 at the same time


I would like to post an url, image and text at the same time to facebook using Sharekit in iOS. Is it possible? If so, how do I do it? Any guidance.

I would like to acheive something like this. Need some help.

I have tried something like this:

SHKFacebook * sharer = [ [ [ SHKFacebook alloc ] init] autorelease ];
    SHKItem * item = [ SHKItem URL:[ NSURL URLWithString:@"http://google.com" ]
                             title:@"my title"
                       contentType:SHKShareTypeURL ];
    item.facebookURLShareDescription = @"my description";
    item.facebookURLSharePictureURI = @"http://www.userlogos.org/files/logos/pek/stackoverflow.png";

But doesn't seem to post with the description...

EDIT:

my facebooksharedescription and facebookshareuri looks like this:

- (NSString *)facebookURLSharePictureURI {
    return nil;
}

- (NSString *)facebookURLShareDescription {
    return nil;
}

Do I need to change anything in this.

When i change to forcepreIOS6posting,it gives me this error:

the operation cannot be completed.(com.facebook.sdk. error 2.)

Need some guidance on these two as well...


Solution

  • see sharer specific extensions in SHKItem.h and DefaultSHKConfigurator.m in ShareKit 2.0. It is clearly described there.

    You can set link, image and description + user can add some message if you decide to present the dialogue to user.

    Note, that this works on ShareKit type of sharing dialogue (pre iOS6). On iOS6 ShareKit uses new native social.framework dialogue, where this type of behaviour is not possible. You can force pre-iOS6 behaviour even on iOS 6 in your configurator subclass (again, for more info check DefaultSHKConfigurator.m.

    If you decide to use ShareKit, make sure to follow sharekit install wiki literally.

    EDIT: this is pasted from ShareKit sample app, ExampleShareLink.m file. It is a content type video, but you can use these facebook sharer specific extensions for any content type.

    SHKItem *item = [SHKItem URL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=3t8MeE8Ik4Y"] title:@"Big bang" contentType:SHKURLContentTypeVideo];
    item.facebookURLSharePictureURI = @"http://www.state.gov/cms_images/india_tajmahal_2003_06_252.jpg";
    item.facebookURLShareDescription = @"description text"; 
    

    EDIT 2: if you followed wiki carefully, you got to the point 4 - Configuration. In your configurator subclass, override

    - (NSNumber*)forcePreIOS6FacebookPosting {
        return [NSNumber numberWithBool:false];
    }
    

    and set to true. You can configure (override) many other things, see DefaultSHKConfigurator.m