我正在尝试创建一个活动,但我读过的所有教程都已过时或不再有效。
[FBRequest
startWithGraphPath:@"me/events"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", result);
} else {
NSLog(@"Success: %@", result);
}
}];
调用完成处理程序,但HTTP错误#403。我做错了什么?
答案 0 :(得分:0)
如果完成处理程序返回HTTP / 403 Forbidden,则您的身份验证有问题。您的Facebook会话可能无效,或根本不开放。请查看Facebook iOS SDK Tutorial以了解如何建立有效会话。从本质上讲,你应该做这样的事情:
static NSString *PublishStreamPermission = @"publish_stream";
[FBSession
openActiveSessionWithPublishPermissions:@[PublishStreamPermission]
defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if ([session state] != FBSessionStateOpen) {
// failed to open a valid session
} else if ([[session permissions] containsObject:PublishStreamPermission]) {
// session opened, permissions granted, now you can post
} else {
// session opened, but requested permissions not granted
}
}];