Tag: PHP

尽pipe有mysql入口,NSArray在iOS中仍然是空的

我一直在尝试用xml输出从PHP脚本中填充Xcode中的数组,以便ios可以连接到mysql。 但是,尽pipe在mysql中有信息,我仍然得到了一个空数组。 这一定意味着我的属性部分或者我对xml的parsing是错误的,但是我真的不知道它究竟是什么错误(并且没有任何数量的主演似乎有帮助)。 我没有得到任何错误从PHP或Xcode。 有任何想法吗? 编辑:我已经按照下面的build议,我仍然得到一个空值,但我相信它来自我的PHP … – (void)viewDidLoad { [super viewDidLoad]; char *cStr = "YES"; NSString *str3 = [NSString stringWithUTF8String:cStr]; NSString *urlString = [NSString stringWithFormat:@"(censored)", _login]; NSXMLParser *Parser = [[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease]; [Parser setDelegate:self]; [Parser parse]; NSDictionary *itemAtIndex =(NSDictionary *)[oneam objectAtIndex:0]; oneam = [[NSMutableArray alloc] init]; if (([[itemAtIndex objectForKey:@"its"]isEqualToString:str3 ])) { [switch1 […]

iOS的JSON错误:NSDebugDescription =结束时的垃圾

这是一个非常奇怪的错误,当从我的服务器(它是通过PHP生成的)抓取JSON时,调用时出现此错误: json = [NSJSONSerialization JSONObjectWithData:kivaData options:kNilOptions error:&jsonError]; JSON错误:错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(cocoa错误3840.)”(垃圾在结束。)UserInfo = 0x178467d00 {NSDebugDescription =垃圾在结束。} 我的(NSData * kivaData)抓住了一切,但它无法parsingJSON。 我已经在http://jsonlint.com/运行我的JSON代码,它出来每次都有效。 它真的很奇怪,因为它可以parsingJSON当我连接到无线上网,但是当我尝试通过手机,它不会工作。 它确实在某些人的手机上通过手机工作,但每次都是这样。

无法validationopenssl公钥

我正在尝试使用openssl_verify()来validation$publicKey 。 这是我的代码: $publicKey = openssl_pkey_get_public($_POST['publicKeyURL']); $playerID = $_POST['playerID']; $timestamp = intval($_POST['timestamp']); $signature = base64_decode($_POST['signature']); $salt = base64_decode($_POST['salt']); $payload = $playerID . $bundleID . $timestamp . $salt; $status = openssl_verify($payload, $signature, $publicKey); openssl_free_key($publicKey); if ($status == 1) { /* */ } 我收到以下错误: openssl_verify()提供的key参数不能被强制转换成公钥 POST信息来自使用此Game Center方法的iOS应用程序。

上传文件只传输less量的数据-IOS

朋友你好,我是iPhone新手。 我想在服务器上传video。 我已经尝试了几种方法,但只有几个字节传输到服务器。 波纹pipe是我的iOS代码 我在这里粘贴了我的代码。 提前致谢。 – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *urlString = [info valueForKey:UIImagePickerControllerMediaURL]; self.videoData = [NSData dataWithContentsOfURL:urlString]; // NSLog(@"%@",self.videoData); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Default Album"]; if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil]; videopath= [[NSString alloc] initWithString:[NSString stringWithFormat:@"%@/Video.mov",documentsDirectory]]; […]

PHP / IOS:什么是最好的方式来编码JSON的Web服务?

我正在尝试创build一个Web服务,通​​过PHP在MySQL应用程序中显示从一个MySQL数据库提供JSON。 我有一个标准的MySQL / PHP设置。 数据在一个带有字段和logging的表格中。 用sql查询来创build一个logging集。 logging集中的每个logging都是一行。 php $sql = "SELECT userid,task,longtask FROM tasks WHERE userid = 1 LIMIT 1"; $res = mysql_query($sql) or die(mysql_error()); $tasks = array(); while($row = mysql_fetch_assoc($res)) { $tasks[] = array('row'=>$row); } echo json_encode(array('tasks'=>$tasks)); // Web服务产生以下输出: {"tasks":[{"row":{"userid":"1","task":"send email to Bob","longtask":"include attached memo"}}]} 然而,我很难把它读入IOS,提示可能有更好的Web服务格式。 这个结构不同于我在阅读json到IOS(其中没有使用php / mysql)的教程和其他资源中的结构。 任何人都可以告诉我一个更好的方法来构造JSON,或者在iOS中读取这个JSON来获取用户标识,任务和其他variables。 当我尝试这个,我得到一个错误,它不能放在行索引:0 NSError* error; NSDictionary* […]

使用PHP发件人和Swift在后台收到IOS GCM推送通知

我正在使用GCM获取背景通知以在IOS上工作 – 非背景通知已经在工作。 以下是我整合背景通知的步骤: 在UIBackgroundmodes中启用remote-notifications标签 将内容可用密钥添加到我的通知负载。 编写应用程序:didRecieveRemoteNotification:fetchCompletionHandler:在我的委托。 以下是委托函数的代码: func application( application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) { println("Notification received2: \(userInfo)") GCMService.sharedInstance().appDidReceiveMessage(userInfo); NSNotificationCenter.defaultCenter().postNotificationName(messageKey, object: nil, userInfo: userInfo) handler(UIBackgroundFetchResult.NoData); } 这是服务器上php脚本的代码: <?php $regId = $_GET["regId"]; $message = $_GET["message"]; $data = array( 'price' => $message, 'sound' => 'default', 'body' => 'helloworld', 'title' […]

如何将数据从iOS应用程序发送到http服务器

我怎样才能从一个iOS应用程序中的string发送一些数据到我的服务器,PHP脚本会将这些数据写入数据库?

如何在Objective-C中使用URL Xcode 8.1在我的PHP服务器中发送数据

我想从Xcode发送NSString数据到我的PHP服务器,在这个例子中使用url: http : //11.1.12.173 : 1000 我需要XCODE 8.1的解决scheme,因为有些代码在最新的Xcode中不起作用。 NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://11.1.12.173:1000"]]; [req setHTTPMethod:@"POST"]; NSData *postData = [deviceToken dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]]; [req addValue:postLength forHTTPHeaderField:@"Content-Length"]; [req setHTTPBody:postData]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { // Do something […]

挣扎从我的iOS上的图像上传到我的PHP服务器

下面的代码用于将图像上传到远程服务器,但由于某种原因,它不适用于我。 当我进入,例如到这个页面,我使用PHP的forms来上传图片,它没有问题。 所以,关于PHP部分,没有一个单一的问题,一切正常。 问题: 那有什么问题? NSData *imageData = UIImageJPEGRepresentation(self.imageViewer.image, 90); NSString *urlString = @"http://example.com/post_image.php"; [request setHTTPMethod:@"POST"]; request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = @"—————————14737809831466499882746641449"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n–%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"Content-Disposition: form-data; name=\"image\"; filename=\".jpg\"\r\n" […]

HTTPS web服务与PHP会话

我需要在使用HTTPS和PHP Session的PHP中构build一个WebService。 我如何从iOS(目标c)获得服务以及如何在login到服务器时保存/使用php的会话?