iPhone - How to send image + text on facebook using sharekit

iPhone - How to send image + text on facebook using sharekit

up vote 0 down vote favorite
share [fb] share [tw]

As per the requirement in my app I want to send image and text(dynamic-written by user) on the facebook. I have already write the code of sending image which is as follows

NSString *str = [NSString stringWithFormat:@"00%d",currentIndex_+1];         NSString *imageIndex = [[NSBundle mainBundle] pathForResource:str ofType:@"png"];         NSLog(@"image index:%@",imageIndex);        // NSData *myData = [[NSData alloc] initWithContentsOfFile:imageIndex];             SHKItem *item = [SHKItem image:[UIImage imageWithContentsOfFile:imageIndex] title:@"sent via iphone"];         [NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item]; 

but now I also want to send text(dynamic) with this image. How can I send text with image?

plz help...

link | improve this question

70% accept rate
 
why don't you use NSString stringWithFormat: i.e.` NSString *var=@"aaa"; SHKItem *item = [SHKItem image:[UIImage imageWithContentsOfFile:imageIndex] title:[NSString stringWithFormat:@"%@ \n%@",var,@"Sent via iSLP Break Roomi iPhone App"]];` –  Michał Zygar  Dec 12 at 11:16
 
but this will be static text I want to send text written by user –  iPhone  Dec 12 at 11:41
 
you can put the text that user had written in NSString *var in my example –  Michał Zygar  Dec 12 at 11:51
feedback

3 Answers

active oldest votes
up vote 0 down vote

It is very easy. Just make sure to #import the SHKItem and SHKFaceBook

UIImage *image = [UIImage imageNamed:@"someImage.png"]; SHKItem *itemToShare = [SHKItem image:image title:@"Some title if you want to"]; [SHKFacebook shareItem:itemToShare]; 
link | improve this answer
 
but I want to send dynamic(written by user) text not static –  iPhone  Dec 12 at 11:51
feedback
up vote 0 down vote

dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ %@\",\"href\":\"\",\"caption\":\"descriptoin\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://example.com/webservices/images/img.png\",\"href\":\"http://%@/\"}]}",name,msg,url];

replace this code with dialog.attachment which is inside the SHKFacebook.m and replace your image url/path which i am written in bold letter.

and post your text using the code :

SHKItem *item1 =[SHKItem text:@"hello"];

[SHKFacebook shareItem:item1];

link | improve this answer
 
feedback
up vote 0 down vote

Call this method to upload with message :

-(void)facebookPhotoUpload {

ShareController *share = [ShareController sharedObject]; share._delegate  = self; if([share isFacebookLoggedIn]){     [share fbUploadPicture:ivwCartoon.image withMessage:@"my message"]; } else {     share.iSelectedShareOption = fbUploadPicture;     [share fblogin]; } 

}

and ShareViewController.m having below method :

-(void)fbUploadPicture:(UIImage )image withMessage:(NSString)message {

iSelectedShareOption = fbUploadPicture; NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:                                 message, @"message",                                 image, @"source",                                 nil]; [self.facebook requestWithGraphPath:@"me/photos"                           andParams:params                       andHttpMethod:@"POST"                         andDelegate:self]; 

}

link | improve this answer

你可能感兴趣的:(image,user,upload,iPhone,Facebook)