使用新的iOS Facebook SDK API上传照片(3.0)
我怎样才能使用他们的新API / SDK从iOS应用上传照片到Facebook? 我已经试过了,我没有得到任何地方,只是继续在圈子里跑。 这是我现在的代码:
-(void)dataForFaceboo{ self.postParams = [[NSMutableDictionary alloc] initWithObjectsAndKeys: self.uploadPhoto.image, @"picture", nil]; } -(void)uploadToFacebook{ [self dataForFacebook]; NSLog(@"Going to facebook: %@", self.postParams); // Hide keyboard if showing when button clicked if ([self.photoCaption isFirstResponder]) { [self.photoCaption resignFirstResponder]; } // Add user message parameter if user filled it in if (![self.photoCaption.text isEqualToString:kPlaceholderPostMessage] && ![self.photoCaption.text isEqualToString:@""]) { [self.postParams setObject:self.photoCaption.text forKey:@"message"]; } [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { NSString *alertText; if (error) { alertText = [NSString stringWithFormat: @"error: domain = %@, code = %d", error.domain, error.code]; } else { alertText = [NSString stringWithFormat: @"Posted action, id: %@", [result objectForKey:@"id"]]; } // Show the result in an alert [[[UIAlertView alloc] initWithTitle:@"Result" message:alertText delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil] show]; }]; }
“我/照片”是为了照片实际上在你的Facebook个人资料的“照片”列表中。 “me / feed”只是时间线上的一个post。
你的代码很好,要做一些小的改动:
以NSData
格式将图像添加到字典中
[params setObject:UIImagePNGRepresentation(_image) forKey:@"picture"];
并将graphicspath更改为"me/photos"
而不是"me/feed"
做这些改变,它为我工作。 请记住,您需要使用“publish_actions”权限。
- iOS 9 Facebooklogin模拟器-canOpenURL:URL失败:“fbauth2:///” – 错误:“(null)”
- FBAudiencenetworking:objc_boxable属性只适用于结构或联合
- 在Facebook上分享应用程序
- 共享应用程序时产生的“FBAppCall无效使用”错误 – Facebook应用程序ID未注册为URLscheme
- 使用iOS应用程序附加的预定义链接撰写消息到Facebook Messenger
- Facebook SDK 3.0:如何接收用户的电子邮件?
- IOS Facebook的SDK – 发布打开graphics和时间轴上显示,无需点击活动日志
- 发布或pipe理权限不被授权读取权限FACEBOOK SDK请求
- phonegap 2.7.0有没有Facebook插件?