简体   繁体   English

如何检测iPhone或iPad的用户代理?

[英]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.

相关问题 当我的用户代理不包含类似的东西时,我如何使用 php 检测用户使用 ipad - How can I detect with php that the user uses an ipad when my user agent doesnt conatin something like that iPad用户代理检测 - iPad user agent detection 我如何使用php分别检测iphone和ipad - How i can detect Iphone and ipad separately using php 是否有模仿User-Agent字符串的iPhone模拟器,所以我可以使用php-mobile-detect? - Is there an iPhone emulator that mimics User-Agent strings so I can use php-mobile-detect? 如何从php中的用户代理字符串中检测浏览器欺骗和机器人 - How to detect browser spoofing and robots from a user agent string in php 如何使用PHP检测“Google Chrome”作为用户代理? - How to detect “Google Chrome” as the user-agent using PHP? 更改用户代理后如何检测真正的IE - How to detect really IE when changed user agent 如何在不使用PHP用户代理的情况下检测虚假的移动流量? - how to detect fake mobile traffic without use user agent in PHP? 如何在Amazon API Gateway上检测GET请求的HTTP用户代理? - How to detect HTTP user agent of GET request on Amazon API Gateway? 使用 php 检测特定的 iPhone 或 iPad 型号 - Detect specific iPhone or iPad model with php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM