[英]How to detect user agent of iphone or ipad?
I am using the following code to parse a remote XML : 我正在使用以下代码来解析远程XML:
NSString *urldata=[[NSString alloc]initWithFormat:@"http://url.com/test/a.php"];
NSString *encode=[urldata stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@" urldata %@",urldata);
TBXML *tbxml =[TBXML tbxmlWithURL:[NSURL URLWithString:encode]];
And my php script has $useragent= $_SERVER['HTTP_USER_AGENT'] ;
而且我的php脚本具有$useragent= $_SERVER['HTTP_USER_AGENT'] ;
. 。 I am unable to determine the user agent. 我无法确定用户代理。 However if call the url from safari ipad or iphone I have the user agent correctly. 但是,如果从Safari ipad或iphone调用URL,我的用户代理正确。
You need to use an NSMutableURLRequest
in your iPhone code where you can set the user agent. 您需要在iPhone代码中使用NSMutableURLRequest
,您可以在其中设置用户代理。 Because it's not being sent to your php webserver as it is not mandatory to send 因为它没有被发送到您的php Web服务器,因为它不是强制发送
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.