4

SLRequestを使用して Facebook の投稿にUIImageを添付する方法。これは私のコードです:

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

パラメータで絵を指定する必要があることは知っていますが、どのように作ればいいのかわかりません。

4

1 に答える 1

6

画像をマルチデータとして「picture」という名前で追加します。

UIImage *myImage = [UIImage imageNamed:@"test.png"];
NSData *myImageData = UIImagePNGRepresentation(myImage);
[facebookRequest addMultipartData:myImageData withName:@"picture" type:@"image/png" filename:nil];
于 2012-10-20T14:01:38.683 に答える