您的位置:首页 > 移动开发 > IOS开发

ios-新浪微博开发-16(授权)

2015-09-18 20:24 393 查看
我们使用三方登录 要或得授权
这里新浪给我们授权
登录页面不用自己写只需要用一个webView 加载新浪给我们发送回来的页面
#import "QHOAushiyongthViewController.h"

@interface QHOAuthViewController()<UIWebViewDelegate>

@end

@implementation QHOAuthViewController

- (void)viewDidLoad {
[super viewDidLoad];

//1.创建webView
UIWebView *webView = [[UIWebView alloc]init];
webView.frame = self.view.bounds;
[self.view addSubview:webView];
webView.delegate = self;
//2.用webView加载登录页面(新浪提供的)
//请求地址:https://api.weibo.com/oauth2/authorize
//请求参数 client_id=438168078&redirect_uri=http://
NSURL *url = [NSURL URLWithString:@"https://api.weibo.com/oauth2/authorize?client_id=438168078&redirect_uri=http://"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];

NSLog(@"-----viewDidLoad");

//invalid_request 参数搞错了 或者没有参数
// Do any additional setup after loading the view.
}

#pragma mark -webView代理方法
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"-----ViewDidFinishLoad");
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"didFailLoadWithError");
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: