4

How to attach the UIImage to the post on Facebook using SLRequest. This is my code:

SLRequest *facebookRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                                 requestMethod:SLRequestMethodPOST
                                                                      URL:[NSURL   URLWithString:@"https://graph.facebook.com/me/feed"]
                                                               parameters:[NSDictionary dictionaryWithObject:post forKey:@"message"]];

I know that it is necessary to specify the picture in parameters, but I do not know as it to make.

Kisel Alexander
  • 750
  • 2
  • 8
  • 25

1 Answers1

6

Add the image as multi-data and with the name "picture".

UIImage *myImage = [UIImage imageNamed:@"test.png"];
NSData *myImageData = UIImagePNGRepresentation(myImage);
[facebookRequest addMultipartData:myImageData withName:@"picture" type:@"image/png" filename:nil];
C Abernathy
  • 5,533
  • 1
  • 22
  • 27