Tag: PHP

我怎样才能在NSDictionary内张贴一个NSDray的NSArray没有问题?

我知道如何做到这一点,这很简单。 问题是它不起作用。 这是我用来POST数据的function: – (void)updateWebsitesUsingParameters:(NSDictionary *)parameters; { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:@"http://notreal/updateWebsites.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); //… } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //… }]; } 这里是参数: NSDictionary *parameters = @{@"type" : @"0", @"credentials" : @{@"email" : @"notreal@gmail.com", @"password" : @"notreal"}, @"device" : @{@"ID" : @"8588107756600540", @"numberOfSessions" : […]

通过php脚本发送iOS通知:“无法设置私钥文件”

我已经使用众所周知的Ray Wanderlich 教程中的php脚本在开发阶段发送推送通知。 在创buildpem文件(来自p12和aps_development.cer文件)之后,它们被正确触发,并在php脚本中提到了设备标记。 但是,当我使用生产p12和aps_production.cer文件的pem文件时,通知甚至不能到达APNS服务器。 它在本地服务器端本身显示下面的错误。 Unable to set private key file `/Users/administrator/Desktop/SimplePush/ck.pem' in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22 Warning: stream_socket_client(): failed to create an SSL handle in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22 Warning: stream_socket_client(): Failed to enable crypto in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22 Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /Users/administrator/Desktop/SimplePush/simplepush.php on line […]

用Swift 3.0parsingJSON数组到Server

我想发送一个JSON数组到Web服务器。 我已经看了几个例子在线,即https://www.youtube.com/watch?v=aTj0ZLha1zE&t和保存CoreData到一个Web服务器与Swift 3.0已经演示了如何parsing数据,但我正在努力实现这一目标。 下面是我应该把数据发送到服务器的function: func sendRecordToServer() -> [Record] { let fetchRequest = NSFetchRequest<NSDictionary>(entityName:"Record") fetchRequest.resultType = .dictionaryResultType do { let records = try context.fetch(fetchRequest) if let jsonData = try? JSONSerialization.data(withJSONObject: records, options: []) { // jsonData is a byte sequence, to view it you would need to convert to string print(String(bytes: jsonData, encoding: String.Encoding.utf8)) let URL_SAVE_DATA […]

从iOS和.NET的PHPencryption差异

在iOS和PHP之间进行encryption通信时遇到问题。 我有一个应用程序,encryption一个string,并将其发送到解密它的PHP服务器。 那部分工作得很好。 现在,PHP服务器需要发送一个encryption的响应回应用程序,这似乎是更多的白发。 问题是,当我在PHP中encryption一个string时,它看起来与在iOS甚至.NET中encryption的string不同 – 显然,所有的地方都使用相同的algorithm,密钥和IV。 我使用CBC模式下的Rijndael 128,包含空字节的IV(到目前为止)。 PHPencryption看起来如此: $encrypted = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $this->secret_key, $str, MCRYPT_MODE_CBC, $this->iv ); $encrypted = base64_encode( $encrypted ); iOSencryption附在这个文件中: StringEncryption.m: http ://pastie.org/1365766 我希望有人能帮我找出我错过了什么东西或有一些不同的价值观。 我已经看了几个小时,找不到其他东西来尝试。

从Swift应用程序发送audio到PHP服务器,以及audio丢失的地方

我正在Swift中制作一个应用程序,用于录制一些audio,然后将该录制内容发送到我的PHP服务器。 该应用程序loggingaudio剪辑罚款(可以播放没有问题)。 当我println录制的audio剪辑时,它显示了加载和加载的字节数据(当我把audio放入一个NSData包装器时)。 这一切都表明,我的应用程序内的audio是好的。 捕捉我的服务器上的logging的PHP文件也工作正常,没有错误。 但是沿线的某处录制的audio剪辑会丢失。 上传logging的Swift代码: // The variable "recordedFileURL" is defined earlier in the code like this: currentFilename = "xxxx.m4a" let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) let docsDir: AnyObject=dirPaths[0] recordedFilePath = docsDir.stringByAppendingPathComponent(self.currentFilename) recordedFileURL = NSURL(fileURLWithPath: self.recordedFilePath) // "currentFilename", "recordedFilePath" and "recordedFileURL" are all global variables // This recording stored at "recordedFileURL" can be […]

PHP Apple iOS推送通知:Command2:二进制接口和通知格式

如今,使用Command 2的PHP和Apple / iOS推送通知已经越来越stream行。 不过不知道,如何根据苹果指南在这里准备相同的格式,如何实现下面的包格式: 还想知道,如何接收Format of error-response packet如下所述: 目前我使用的格式如下: $msg = // new: Command "1" chr(1) // new: Identifier "1111" . chr(1) . chr(1) . chr(1) . chr(1) // new: Expiry "tomorrow" . pack('N', time() + 86400) // old . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . […]

PHP iOS的AESencryption

我一直在尝试使用AESencryption在PHP和我的iOS应用程序之间进行通信。 到目前为止,我已经考虑了两种实现方法。 首先是使用OpenSSL。 在iOS方面,我以一种模仿这里显示的代码的方式实现: http : //saju.net.in/code/misc/openssl_aes.c.txt 。 在PHP方面,我把生成的密钥和IV(来自iPhone)并将其用作PHP opensslencryption的input。 结果在输出方面不同 我也考虑过: http : //iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html 但是这个post: iOS和PHP之间的AESCrypt解密令我震惊 。 这个项目并不局限于AES,它似乎是一个强大的encryptionalgorithm,不会太难实施。 我的基本问题是:什么是最简单的方法来实现一个好的encryptionalgorithm,可以很容易地使用iOS和PHP之间的沟通?

在推送通知中通过PHP在iOS上发送表情符号

我想通过推送通知发送一些表情符号图标,但不知道如何做到这一点。 有没有人用PHP成功实现了这个? 举个例子,我只是想以一个笑脸作为前提。 我的问题纯粹是关于表情符号,我有一个成功的APNS脚本。 感谢您的任何指导。

从iOS应用程序发送到PHP脚本不工作…简单的解决scheme是likey

我已经做了几次之前,但由于某种原因,我不能得到的职位去通过…我尝试的PHP脚本的variables设置为_POST,没有…当他们没有设置发布它的作品精细。 这是我的iOS代码: NSDate *workingTill = timePicker.date; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"HH:mm"]; NSString *time = [formatter stringFromDate:workingTill]; NSString *post = [NSString stringWithFormat:@"shift=%@&username=%@", time, usernameString]; NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO]; NSString *postLength = [NSString stringWithFormat:@"%d", [post length]]; NSURL *url = [NSURL URLWithString:@"http://wowow.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [request setHTTPMethod:@"POST"]; NSLog(@"%@", post); […]

POST和SWIFT和API

当我尝试向我的服务器上的API发送POST请求时遇到了问题,我遵循许多不同的教程,但仍然无效。 我知道比我的问题是与POST请求,但我不能解决它! 所以这是我在Swift中的代码和我在PHP中的API :(是的,我已经用我的代码中的真实IDreplace了xxxx) 总结服务器接收请求,例如,如果我手动input一个伪它工作,这真的是POST方法谁不工作。服务器没有收到POST参数 SWIFT代码 : var request = NSMutableURLRequest(URL: NSURL(string: "http://localhost:8888/academy/test.php")!) var session = NSURLSession.sharedSession() request.HTTPMethod = "POST" var params = ["pseudo":"test"] as Dictionary<String, String> var err: NSError? request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &err) request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.addValue("application/json", forHTTPHeaderField: "Accept") var task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in println("Response: […]