2012-08-27 2 views
1

내 프로젝트 사용자는 Facebook 기본 응용 프로그램 (FBConnect)을 통해 로그인하고 사용자의 액세스 토큰을 보관했습니다. 내 애플 리케이션에서 버튼처럼 facebook 페이지의 iframe을 표시하는 버튼을 가지고 있고 사용자가 버튼처럼 페이지를 누를 때 페이스 북은 사용자에게 다시 로그인하도록 요청합니다. 사용자가 현재 로그인되어 있고 토큰이 validand이고 iframe에 액세스 토큰을 전달하고 있습니다. 여기 iframe을 만드는 데 사용하는 코드가 있습니다.uiwebview에서 (iFrame을 통해) facebookpage와 같은 액세스 토큰을 얻는 방법은 무엇입니까?

NSString *str=[NSString stringWithFormat:@"<iframe src=\"https://www.facebook.com/plugins/likebox.php?id=XXXXXXXXXXXXXXX&access_token=%@&amp;width=292&amp;connections=0&amp;stream=false&amp;header=false&amp;height=62\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:282px; height:62px;\" allowTransparency=\"true\"></iframe>",accesstoken]; 
NSString *likeButtonHtml = [NSString stringWithFormat:@"<HTML><BODY>%@</BODY></HTML>", str]; 
    [webview loadHTMLString:likeButtonHtml baseURL:[NSURL URLWithString:@""]]; 

난 당신이있는 UIWebView로 로그인해야 iframe을

+0

코드는 다음과 같습니다

[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { switch (status) { case FBSessionStateOpen: // call the legacy session delegate //Now the session is open do corresponding UI changes break; case FBSessionStateClosedLoginFailed: { // prefer to keep decls near to their use // unpack the error code and reason in order to compute cancel bool NSString *errorCode = [[error userInfo] objectForKey:FBErrorLoginFailedOriginalErrorCode]; NSString *errorReason = [[error userInfo] objectForKey:FBErrorLoginFailedReason]; BOOL userDidCancel = !errorCode && (!errorReason || [errorReason isEqualToString:FBErrorLoginFailedReasonInlineCancelledValue]); // call the legacy session delegate if needed //[[delegate facebook] fbDialogNotLogin:userDidCancel]; } break; // presently extension, log-out and invalidation are being implemented in the Facebook class default: break; // so we do nothing in response to those state transitions } }]; 

내 샘플 코드를 확인? 그리고 이것이 iframe에 관한 질문 인 경우 질문에 "iOS"및 "Objective-C"라는 태그가 붙은 이유는 무엇입니까? –

+0

@NSPostWhenIdle 코드를 편집했습니다 – prakhar

+0

나는 Android와 똑같은 문제가 발생합니다. 하지만 그 대답은 거의 동일합니다. http : //stackoverflow.com/questions/12464570/facebook-like-button-in-webview-with-sdk – Warlock

답변

관련 문제