Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to post URL with Image on facebook by ShareKit

I am using sharekit in my iPhone app to share url link on facebook. However, it seems to me that it is not possible to share url with image with sharekit. Do you guys know how to do it? Thanks a lot.

like image 482
justicepenny Avatar asked Jan 14 '11 18:01

justicepenny


1 Answers

Please have a look to the code I just made my own Send method in SHKFacebook.m/h files, I think it will help you.

  -(BOOL) sendWithImage :(NSString*)creativeUrl 
   {
            self.pendingFacebookAction = SHKFacebookPendingStatus;

        SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease];
        dialog.delegate = self;
        dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:");
        dialog.attachment = [NSString stringWithFormat:
                             @"{\
                             \"name\":\"%@\",\
                             \"href\":\"%@\",\
                             \"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]\
                             }",
                            item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title),
                            SHKEncodeURL(item.URL),
                            creativeUrl,
                            SHKEncodeURL(item.URL) 

                        ];
    dialog.defaultStatus = item.text;
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]",
                            SHKEncode(SHKMyAppName),
                            SHKEncode(SHKMyAppURL)];
    [dialog show];
    return YES; 

}

Here is How I Use it

SHKFacebook *fb =[[SHKFacebook alloc]init];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@iphone/photo?id=%d",[SplashViewController getBaseURL],[photoId intValue]]];
    fb.item = [SHKItem URL:url title:[dicResult valueForKey:@"Caption"]];
    //fb.shareType = SHKShareTypeURL;
    fb.quiet = YES;
    [TedryUITabBarController updateProgress:10 totalByteToSent:11 message:@"Sharing on facebook"];
    [fb sendWithImage:[dicResult valueForKey:@"CreativeURL"] :@""]; 
like image 181
Akbar Khan Avatar answered Oct 19 '22 23:10

Akbar Khan