Php 如何检测iphone或ipad的用户代理?

Php 如何检测iphone或ipad的用户代理?,php,iphone,web-services,user-agent,Php,Iphone,Web Services,User Agent,我使用以下代码解析远程XML: NSString *urldata=[[NSString alloc]initWithFormat:@"http://url.com/test/a.php"]; NSString *encode=[urldata stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@" urldata %@",urldata); TBXML *tbxml =[TBXML tbxmlWithU

我使用以下代码解析远程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]];

我的php脚本有
$useragent=$\u服务器['HTTP\u USER\u AGENT']。我无法确定用户代理。但是,如果从safari ipad或iphone调用url,我的用户代理就正确了。

您需要在iphone代码中使用
NSMutableURLRequest
,您可以在其中设置用户代理。因为它没有被发送到您的php Web服务器,因为它不是强制发送的

Hello,这意味着我必须更改我的应用程序中的代码,我不想更改,因为我将不得不重新上传应用程序。恐怕这是唯一的解决方案。也许你可以获取设备屏幕大小或其他信息来确定它是iPhone还是iPad?你可以使用两个不同的url,例如a.php用于应用程序(因为你不想重新提交应用程序),b.php用于其他流量