我正在使用 FBGraph API 将 FaceBook 集成到我的 iOS 应用程序中,我想“喜欢/分享”特定页面相册或 friend 相册中的照片。是否可以?任何人都可以帮助我吗?
最佳答案
试试这个,它可能对你有帮助。
在 post action 方法中编写以下代码来分享照片。
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:1];
NSURL *imageURL = [[NSURL alloc] initWithString:@"http://track_images/images/20120209104734baby-puppy.jpg"];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL];
UIImage *picture = [UIImage imageWithData:imageData];
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
[variables setObject:graph_file forKey:@"file"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"117795728310/photos" withPostVars:variables];
NSString *res = fb_graph_response.htmlResponse;
NSLog(@"res>> %@",res);
NSRange wordRange = NSMakeRange(0,2);
NSArray *firstWords = [[res componentsSeparatedByString:@"\""] subarrayWithRange:wordRange];
if (![[firstWords objectAtIndex:1] isEqualToString:@"error"]){
//alert for image posted sucessfully.
}
else{
//alert for image not posted sucessfully.
}
关于iphone - iOS - 我如何使用 FBGraph API "Like/Share"来 self 的应用程序的特定页面的任何照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12489107/