开发者

HTTP Headers for Basic Authentication on XCODE iPhone

I want to show one webpage. To show that webpage, I need to put a token (that I already have) that will be given in the HTTP Header in the "Authorisation" field.

for the moment, I开发者_如何学Go try to use that code :

NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", token ];
    NSURLRequest *requestObject = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xxx.com/api_dev.php/1308149125"]];

And then after, I put the webpage into the webView (This code is running):

[webView loadRequest:requestObject];//load the URL into the web view.
    [self.view addSubview:webView];//add the web view to the content view.

Thanks for help me


Just put

NSString *authHeader = [@"" stringByAppendingFormat:@"%@", token ;
    NSMutableURLRequest *requestObject = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://xxx.com/1308149125"]];
    [requestObject setValue:authHeader forHTTPHeaderField:@"App-Token"];

So, add the last line, and delete the "Basic " before the token

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜