views:

307

answers:

1

i try to request on my application via this url

http://reader.mac.com/mobile/v1/http%3A%2F%2Ffeeds.feedburner.com%2F9To5Mac-MacAllDay

and it also return that it available on iPhone only

how can i fix it?

mycode

NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: myurl]];
    [urlRequest setValue: @"iPhone" forHTTPHeaderField: @"Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"];
    [self.myWebView loadRequest:urlRequest];
A: 

The name of the http header field is User-Agent. Try this:

    [urlRequest setValue: @"Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" 
      forHTTPHeaderField: @"User-Agent"];
MacTouch
thanks MacTouch but it also not work, the url return that my request are not from iPhone.
RAGOpoR
I tried it by myself. UIWebView seems to ignore request header field changes. Setting the User-Agent-Field in the WebViewDelegate (shouldStartLoadWithRequest) or using a subclass of NSMutableURLRequest which ignores changes to User-Agent did not work. Hmmm... no idea what else to do. Maybe you could load the contents of the url into a temporary file(s) and then point UIWebView to the location where it is placed using file:// url (see UIWebView#loadHTMLString and UIWebView#loadData).
MacTouch
thanks again MacTouch, anyway i dont know why i just use FireFox it can switch user agent as iPhone and it can open that URL.
RAGOpoR