NSString *customMessage = [NSString stringWithFormat:@"CUSTOM MESSAGE"];
NSString *postName = @"SAMPLE_APP";
NSString *serverLink = [NSString stringWithFormat:@"http://www.google.co.in "];
NSString *imageSrc = @"PATH OR URL TO IMAGE";
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init]autorelease];
[dictionary setObject:postName forKey:@"name"];
[dictionary setObject:serverLink forKey:@"href"];
[dictionary setObject:customMessage forKey:@"description"];
NSMutableDictionary *media = [[[NSMutableDictionary alloc] init]autorelease];
[media setObject:@"image" forKey:@"type"];
[media setObject:serverLink forKey:@"href"];
[media setObject:imageSrc forKey:@"src"];
[dictionary setObject:[NSArray arrayWithObject:media] forKey:@"media"];
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = @"Share with All";
dialog.attachment = [dictionary JSONFragment];
[dialog show];
Где метод JSONFragment просто преобразует вложение в эквивалентный формат JSON
- (NSString *)JSONFragment {
SBJsonWriter *jsonWriter = [SBJsonWriter new];
NSString *json = [jsonWriter stringWithFragment:self];
if (!json)
NSLog(@"-JSONFragment failed. Error trace is: %@", [jsonWriter errorTrace]);
[jsonWriter release];
return json;
}
Надеюсь, это поможет вам.