我在使用Facebook sdk的iOS应用程序发布图像时遇到了一些问题,每次我从我的应用程序发布图像时都要求获得我的实际Facebook帐户的许可。
这是我的功能,将图片发布到Facebook
- (void) postImageToFB:(UIImage*)image
{
NSLog(@"posImagetoFB was called...");
NSData* imageData = UIImagePNGRepresentation(image);
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"This is my drawing!", @"message",
imageData, @"source",
nil];
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(error)
{
NSLog(@"erro has occured %@",error);
}
if(result)
{
NSLog(@"result is %@",result);
}
}];
}
这是我用来登录Facebook的代码
- (void)openSession
{
NSArray *permissions = [NSArray arrayWithObjects:@"user_photos",
nil];
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
提前致谢。
答案 0 :(得分:0)
我认为你应该像这样添加对数组的publish_stream权限:
NSArray * permissions = [NSArray arrayWithObjects:@“user_photos”,@“publish_stream”,nil];
允许您在不经许可的情况下一次又一次地发布图像。