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
精彩评论