Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php命令从iPhone获取udid值?_Php_Iphone - Fatal编程技术网

如何使用php命令从iPhone获取udid值?

如何使用php命令从iPhone获取udid值?,php,iphone,Php,Iphone,当我构建iPhone应用程序的第一个版本时,我忘了输入session命令。现在,我在每个PHP函数中编写了一个会话检查命令 但是,第一个版本工作不好,因为它有时会丢失会话。很多人已经在使用第一个版本了,现在无法更改 所以,我在想,如果我可以通过使用php命令获得iPhone的udid值,我可以为丢失会话数据的用户提供一个新的会话值。或者有没有其他解决方案来实现这一点 谢谢。您可以使用webservice将udid从iphone发送到php,然后您可以访问它 NSString *token=[N

当我构建iPhone应用程序的第一个版本时,我忘了输入session命令。现在,我在每个PHP函数中编写了一个会话检查命令

但是,第一个版本工作不好,因为它有时会丢失会话。很多人已经在使用第一个版本了,现在无法更改

所以,我在想,如果我可以通过使用php命令获得iPhone的udid值,我可以为丢失会话数据的用户提供一个新的会话值。或者有没有其他解决方案来实现这一点


谢谢。

您可以使用webservice将udid从iphone发送到php,然后您可以访问它

 NSString *token=[NSString stringWithFormat:@"%@",deviceToken];
token= [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
token= [token stringByReplacingOccurrencesOfString:@">" withString:@""];
token= [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *post = [NSString stringWithFormat:@"token=%@",token];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.server.com/web-service/save-token.php?"]]];
 [request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnstring = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSString*token=[NSString stringWithFormat:@“%@”,deviceToken];
token=[token StringByReplacingOfString:@“with String:@]”的发生率;
token=[token StringByReplacingOfString:@“with String:@]”的发生率;
NSString*post=[NSString stringWithFormat:@“令牌=%@”,令牌];
NSData*postData=[post数据使用编码:NSASCIIStringEncoding allowLossyConversion:是];
NSString*postLength=[NSString stringWithFormat:@“%d”,[postData长度]];
NSMutableURLRequest*请求=[[[NSMutableURLRequest alloc]init]autorelease];
[请求设置URL:[NSURL URLWithString:[NSString stringWithFormat:@]http://www.server.com/web-service/save-token.php?"]]];
[请求设置HttpMethod:@“POST”];
[请求设置值:HttpHeaderField的postLength:@“内容长度”];
[请求设置值:@“应用程序/x-www-form-urlencoded”用于HttpHeaderField:@“当前类型”];
[请求setHTTPBody:postData];
NSData*returnData=[NSURLConnection sendSynchronousRequest:request returningResponse:nil错误:nil];
NSString*returnstring=[[NSString alloc]initWithData:returnData编码:NSUTF8StringEncoding];
Apple不再允许开发者访问设备标识符。