如何检测除Safari以外的iPhone应用程序中运行的php网页

如何检测除Safari以外的iPhone应用程序中运行的php网页,php,objective-c,xcode,Php,Objective C,Xcode,我已经构建了一个iPhone应用程序(不是iPad),我正在网络视图控制器中运行一个网页。我的问题是PHP文件如何检测到它是从这个应用程序的UIWebView控制器而不是Safari中运行的。如果在这个应用程序中运行,我希望PHP页面的反应与safari mobile web浏览器不同(即去掉html菜单)。这可能吗 网络视图控制器 #import "AccountViewController.h" @interface AccountViewController () @end @imp

我已经构建了一个iPhone应用程序(不是iPad),我正在网络视图控制器中运行一个网页。我的问题是PHP文件如何检测到它是从这个应用程序的UIWebView控制器而不是Safari中运行的。如果在这个应用程序中运行,我希望PHP页面的反应与safari mobile web浏览器不同(即去掉html菜单)。这可能吗

网络视图控制器

#import "AccountViewController.h"

@interface AccountViewController ()

@end

@implementation AccountViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidLoad];
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"account" ofType:@"html"]isDirectory:NO];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [_AccountWebView loadRequest:requestObj];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    NSHTTPCookieStorage *sharedHTTPCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    NSArray *cookies = [sharedHTTPCookieStorage cookiesForURL:[NSURL URLWithString:@"http://www.uniitee.com"]];
    NSEnumerator *enumerator = [cookies objectEnumerator];
    NSHTTPCookie *cookie;
    while (cookie = [enumerator nextObject]) {
        NSLog(@"COOKIE{name: %@, value: %@}", [cookie name], [cookie value]);
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
PHP文件

<?php require_once('Connections/Uniitee.php'); 

$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");

if ($iphone || $android || $palmpre || $ipod || $berry == true) 
{ 
   header('Location: login-m.php');
}

?>

您可以在应用程序中加载不同的URL参数,例如
?appview=true
,在PHP中使用
if($\u GET['appview'])


然后,您可以设置一个会话,让app view在整个用户会话中使用

是的,我试过了,但由于网站范围广泛,因此存在一个风险参数无法携带。有可靠的检测方法吗?我知道,这就是为什么我建议使用会话来存储用户正在使用应用程序的信息。除此之外,我不知道有什么方法可以让PHP检测到应用程序正在使用。好的,是的,我认为会话会很好,我会尝试一下,谢谢!