I've set up Facebook connect with my app using the demo project provided by Facebook. Everything works great, except for the last little step...
First of all, I login and get permissions.
Next, I upload a picture. This works great, I can see the picture in my Facebook album like I should be able to.
When this picture is uploaded, I get it's URL (returned by the FBRequest delegate). Copy pasting this URL into a web browser takes me directly to the image, so I know that this URL is correct.
Here's where the problem is:
Here's the code I'm using for the last part:
- (void)request:(FBRequest *)request didLoad:(id)result {
NSString* picUrl = [result objectForKey:@"src_big"]; //this definitely returns the right URL
if (picUrl)
{
NSString *message = @"Test status";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, @"message", picUrl, @"picture", @"Look at my photo", @"name", nil];
[facebook requestWithMethodName:@"facebook.Stream.publish" andParams:params
andHttpMethod:@"POST" andDelegate:self];
}
}
Any ideas what I'm missing or doing wrong?
Fixed with the following code (after a lot of failed attempts). Facebook doesn't like the way I was trying it, you've got to do it all in just one step:
NSData *imageData = UIImagePNGRepresentation(image);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Test message", @"message", imageData, @"source", nil];
[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With