与Facebook和服务器端验证的ios身份验证
问题描述:
我的iOs应用使用Facebook-sdk对Facebook用户进行身份验证。与Facebook和服务器端验证的ios身份验证
现在应用程序连接到服务器并且必须确认用户身份。哪个是推荐的方式? 可能iphone必须发送某种令牌给服务器,并且服务器必须通过Facebook的api调用确认它
您是否有链接到这些文档?
答
您好ü要在iOS应用程序与Facebook登录我有使用此代码为它请检查 先取Web视图中你读应用程序,并做护理文件的连接。而输入你的Facebook申请
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *client_id = @"Enter your Application ";
NSString *redirect_uri = @"http://www.facebook.com/connect/login_success.html";
NSString *url_string = [NSString stringWithFormat:@"https://graph.facebook.com/oauth/authorize?client_id=%@&redirect_uri=%@&type=user_agent&display=touch", client_id, redirect_uri];
NSURL *url = [NSURL URLWithString:url_string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
-(IBAction)getText:(id)sender{
NSLog(@"%@",[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"]);
}
- (void)webViewDidFinishLoad:(UIWebView *)_webView {
NSString *url_string = [((_webView.request).URL) absoluteString];
NSLog(@"%@",url_string);
NSRange access_token_range = [url_string rangeOfString:@"access_token="];
//coolio, we have a token, now let's parse it out....
if (access_token_range.length > 0) {
int from_index = access_token_range.location + access_token_range.length;
NSString *access_token = [url_string substringFromIndex:from_index];
NSLog(@"access_token: %@", access_token);
htmldata=[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];
NSLog(@"%@",htmldata);
NSLog(@"%@",url_string);
NSArray *arr1=[htmldata componentsSeparatedByString:@"<title>"];
NSString *data=[arr1 objectAtIndex:1];
NSArray *arr2=[data componentsSeparatedByString:@"</title>"];
value=[[NSString alloc]initWithString:[arr2 objectAtIndex:0]];
NSLog(@"%@",value);
if([value isEqualToString:@"Success"])
{
MainScreenController *C = [[MainScreenController alloc]init];
[self.navigationController pushViewController:C animated:YES];
[C release];
}
}
}
感谢
感谢,但这并不使用SDK - 这是标准的方式... – 2012-03-10 04:23:41
现在没有任何其他途径知道登录成功。而otherway使用Facebook的对话框,但你不能从中得到任何价值成功或不会失败.u有改变Facebook的SDK的API和苹果可能会拒绝它。 – parag 2012-03-10 04:34:10