iphone - iOS - 我如何使用 FBGraph API "Like/Share"来 self 的应用程序的特定页面的任何照片?

标签 iphone ios facebook facebook-like fb-graph

我正在使用 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/

相关文章:

iphone - iphone应用程序会保留sqlite数据库吗

带有垂直字母滚动条的 iPhone View (如联系人/FB 好友 View )

ios - 在诸如fetchIfNeededInBackgroundWithBlock之类的 block 中使用PFObject的子类时出现问题

ios - 如何将 Xcode 4.2 的 iOS 反汇编从 Thumb 切换到 ARM?

android - 使用 FacebookDialog 在 Facebook 上发布照片

iphone - 如何在特定日期举办事件?

iphone - 显示触摸按钮的提示

iPhone 使工具栏在 UITableView 中可见

java - Facebook 好友选择器 SDK 示例无法在 Android 上运行

facebook - Grails Spring Facebook从DB加载Facebook凭据