Reputation: 1364
I am trying to upload the text with image using FBRequestConnection
like as follow but I am only able to upload text,not the image.
But when I am giving any image link in place of img1(image) then I am able to see the image on the facebook wall.
UIImage *img1 = [UIImage imageNamed:@"[email protected]"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"https://developers.facebook.com/ios", @"link",
img1, @"picture",
@"Facebook SDK for iOS", @"name",
@"build apps.", @"caption",
@"imagae description.", @"description",
nil];
[params setObject:@"post message" forKey:@"message"];
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
@"error: domain = %@, code = %d",
error.domain, error.code];
} else {
alertText = @"Posted successfully.";
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}];
I have taken the two permission @"publish_actions",@"user_photos"
Please let me know where I am wrong in this code.
Upvotes: 1
Views: 5177
Reputation: 152
Change @"picture" to @"source". If you are using new Facebook 3.1 SDK you can do it simpler:
FBRequest *req = [FBRequest requestForUploadPhoto:img1];
[req.parameters addEntriesFromDictionary:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"post message", @"message", nil]];
FBRequestConnection *con = [[FBRequestConnection alloc] init];
[con addRequest:req completionHandler....
Upvotes: 2
Reputation: 3231
Check out my answer in the IOS Facebook SDK 3 upload image with message
It is the similar way which you required. Just add some more parameters as per your requirements.
Upvotes: 4