我正在使用以下代码在Facebook的用户墙上发布图片
NSData *imageData =UIImagePNGRepresentation(newPageView.image);
UIImage *picture = [UIImage imageWithData:imageData];
NSLog(@"picture is %@",picture);
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
[variables setObject:graph_file forKey:@"file"];
[variables setObject:@"this is a test message: postPictureButtonPressed" forKey:@"message"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"/me/photos" withPostVars:variables];
以上代码在照片相册中发布图片。我可以将其更改为在墙上发布图像吗?
答案 0 :(得分:1)
试试这段代码
NSURL *url = [NSURL URLWithString:@"YOur Image url"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
[variables setObject:img forKey:@"picture"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"/me/photos" withPostVars:variables];