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

来源:互联网 发布:常用的组态软件 编辑:程序博客网 时间:2024/05/17 23:26
我们使用三方登录 要或得授权 这里新浪给我们授权 登录页面不用自己写只需要用一个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

0 0
原创粉丝点击