Jon Schlossberg
Jon Schlossberg

Reputation: 409

Trying to send a local image via ShareKit to Facebook

I'm trying to modify ShareKit to send an image from my iPhone application to Facebook. I also want to pre-populate the share pop-up window type-in box with some text and send a URL. I created a new method to do all this:

+ (SHKItem *)URL:(NSURL *)url title:(NSString *)title text:(NSString *)text picURL:(NSURL *)picURL
{
    SHKItem *item = [[SHKItem alloc] init];
    item.shareType = SHKShareTypeURL;
    item.URL = url;
    item.title = title;
    item.text = text;
    item.picURL = picURL;
    return [item autorelease];
}

Then within the send method in SHKFacebook I check if picURL exists and send to Facebook:

if (item.picURL) {
  dialog.attachment = [NSString stringWithFormat:
                          @"{\
                          \"name\":\"%@\",\
                          \"href\":\"%@\",\
                          \"media\":[{\"type\":\"image\",\
                          \"src\":\"%@\",\
                          \"href\":\"http://itunes.apple.com/us/app/XXXXXX/\"}]}",
                        item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                        SHKEncodeURL(item.URL),
                        SHKEncodeURL(item.picURL)
                        ];
        }

Everything is fine. But I already have the images within my iPhone app and would strongly prefer not to have to retrieve them across the internet.

Is there a way to use UIImageJPEGRepresentation to include the image directly into the dialog.attachment above? I can't figure it out. Other answers to similar questions all involve retrieving the URL across the net.

Many thanks!

Upvotes: 1

Views: 455

Answers (1)

Daniel Amitay
Daniel Amitay

Reputation: 6667

This is unfortunately impossible with ShareKit (I've used ShareKit myself). At some point, you will have to upload the image somewhere, be it some image server or Facebook--before you can share the image. (Don't forget, sharing the image is a completely different thing then merely uploading to Facebook)

This Facebook document outlines the accepted parameters which are reflected in your question: http://developers.facebook.com/docs/guides/attachments/ As you can see, they always require a URL for the media sharing.

I would recommend that you build out the system for yourself using the Facebook iOS SDK.

Upvotes: 1

Related Questions