我想展示一个网页。 为了显示该网页,我需要在“授权”字段的HTTP标题中添加一个令牌(我已经拥有)。
目前,我尝试使用该代码:
NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", token ];
NSURLRequest *requestObject = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xxx.com/api_dev.php/1308149125"]];
然后,我将网页放入webView(此代码正在运行):
[webView loadRequest:requestObject];//load the URL into the web view.
[self.view addSubview:webView];//add the web view to the content view.
感谢您的帮助
答案 0 :(得分:0)
刚刚放
NSString *authHeader = [@"" stringByAppendingFormat:@"%@", token ;
NSMutableURLRequest *requestObject = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://xxx.com/1308149125"]];
[requestObject setValue:authHeader forHTTPHeaderField:@"App-Token"];
因此,添加最后一行,并在令牌
之前删除“基本”