Facebook Connect ボタンを作成しようとしていますが、接続時に FBGraphUser を取得する必要があります。Button に次のコードがあります。
-(IBAction)fbButtonClickHandler:(id)sender {
mainDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
if (mainDelegate.fbSession.isOpen) {
[mainDelegate.fbSession closeAndClearTokenInformation]; // FB delog
}
else {
if (mainDelegate.fbSession.state != FBSessionStateCreated) {
mainDelegate.fbSession = [[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@"email", @"publish_actions", @"user_birthday",nil]];
}
// loggin on facebook
[mainDelegate.fbSession openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
[fbButton setTitle:[self updateFbButtonLabel] forState:UIControlStateNormal];
// reading the documentation i'm trying this to get the FBGraphUser
if(session.isOpen) {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphUser> user, NSError *error) {
if (!error) {
NSString *userInfo = @"";
// Example: typed access (name)
// - no special permissions required
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Name: %@\n\n",
user.name]];
// Example: typed access, (birthday)
// - requires user_birthday permission
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Birthday: %@\n\n",
user.birthday]];
// Display the user info
NSLog(@"%@", userInfo);
}
NSLog(@" error: %@" , error);
}];
}
}
}];
}
}
問題は、私が呼び出すと失敗することですstartForMeWithCompletionHandler
:
エラー: HTTP ステータス コード: 400 FBSDKLog: 応答: 操作を完了できませんでした。(com.facebook.sdk エラー 5.) (ヌル) エラー: エラー ドメイン=com.facebook.sdk コード=5 「操作を完了できませんでした。 (com.facebook.sdk エラー 5.)" UserInfo=0x925f760 {com.facebook.sdk:ParsedJSONResponseKey= {タイプ = 変更可能な辞書、カウント = 2、 エントリ => 1 : {内容 = "コード"} = {値 = +400、タイプ = kCFNumberSInt32Type} 2 : {contents = "body"} = {type = mutable dict、count = 1、 エントリ => 11 : {contents = "error"} = {type = mutable dict、count = 3、 エントリ => 2 : {contents = "type"} = {contents = "OAuthException"} 3 : {contents = "message"} = {contents = "アクティブなアクセス トークンを使用して、情報を照会する必要があります。 現在のユーザー。"} 6 : {内容 = "コード"} = 2500
何か不足していますか?