我在从使用 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];
}];
}
提前致谢。