Tag: PHP

使用PHP的iOS MDM推送通知,不工作

我知道这是重复的 ,但这不是为我工作。 我的PHP代码发送通知是 // Put your device token here (without spaces): $deviceToken = '6hPQc2HvdA20XGlQkznJxlappCrzm3kJccljjOsgF2k=\n'; #base64 encoded // Put your private key's passphrase here: $passphrase = 'Temp1234'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', './Certificates_push_dev_new.pem'); stream_context_set_option($ctx, 'ssl', 'cafile', './entrust_2048_ca.cer'); stream_context_set_option($ctx, 'ssl', 'verify_peer', true); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); // Open a connection to the APNS server $fp = […]

ApnsPHP:推送通知工作在开发,但不是在生产

是的:这个问题有很多重复,但没有任何答案有帮助。 我正在使用Ali Hafizji关于使用APNS服务进行推送通知的伟大教程 。 以开发模式testingAPNS: 下载aps_development.cer 导出证书的私钥( aps_development_key.p12 ) 然后我使用下面的命令(使用terminal)将两者结合起来: openssl x509 -in aps_development.cer -inform der -out aps_development.pem openssl pkcs12 -nocerts -out aps_development_key.pem -in aps_development.p12 cat aps_development.pem aps_development_key.pem > final_aps_development.pem 和(在服务器上使用ApnsPHP)我可以用这个configuration成功发送推送通知: … $push = new ApnsPHP_Push(ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,'final_aps_development.pem'); $push->setRootCertificationAuthority('entrust_root_certification_authority.pem'); $push->setProviderCertificatePassphrase('mypassword'); … 一个旁注:我从https://github.com/jonathanrcarter/push2press entrust_root_certification_authority.pem,正确的地址寻找它可能是https://www.entrust.net/downloads/binary/entrust_2048_ca.cer (无论如何他们是同样的事情)。 在这种情况下,应用程序以debugging模式运行(在设备上,从XCode运行),一切工作正常。 在生产模式下testingAPNS: 要在生产模式下testingAPNS,我将AdHoc分发应用程序归档,并使用iPhoneconfiguration实用程序将其安装到设备上。 我使用aps_production.cer来执行相同的过程来final_aps_production.pem 。 砰,被称为发送推送通知的PHP脚本返回HTML状态码500。 $push代是当然修改生产模式: … $push = new ApnsPHP_Push(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,'final_aps_production.pem'); $push->setRootCertificationAuthority('entrust_root_certification_authority.pem'); […]

麻烦在图像上传时将variables传递给PHP脚本

我有一个脚本,成功地通过PHP将图像上传到我的服务器。 上传部分工作,但我也试图将variables传递给上传图像的PHP脚本。 我相当有信心,我的PHP代码是好的,我只是不知道什么是错的Objective-C。 我也注意到,我从来没有调用NSData * … = [NSData dataWithContentsOfURL:[NSURL URLWithString:…]]; 但我不知道这是否是问题… NSData *data = UIImageJPEGRepresentation(twitterImage, 90); NSString *profileId = [[NSUserDefaults standardUserDefaults] stringForKey:@"passedId"]; NSString *userId = [[NSUserDefaults standardUserDefaults] stringForKey:@"userId"]; NSString *urlString = [NSString stringWithFormat:@"http://www.website.com/user_photo_upload.php? member_id=%@&profile_id=%@",userId, profileId]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = @"_783465873689273842734"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; […]

Base64通过HTTP POST丢失数据(Objective-C)

我目前有一个HTTP POST请求和一个Base64编码库,我编码我的图像到B64然后发送通过HTTP通过POST方法。 我输出Base64到XCodes控制台,复制并粘贴它,它完美的工作。 尽pipe数据库中的Base64 I存储(MongoDB,纯文本文件等)总是在另一端损坏。 工作版本(复制并从XCode粘贴): http : //dontpanicrabbit.com/api/working.php破碎的版本(来自MongoDB数据库): http : //dontpanicrabbit.com/api/grabimage.php 如果您查看源代码,您会注意到它们是相同的,但是在破损的版本中添加了空格。 我正在使用的Objective-C代码是: MyImage.image = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *imageData = UIImageJPEGRepresentation(MyImage.image, 0); [Base64 initialize]; NSString *encoded = [Base64 encode:imageData]; NSString *urlPOST = encoded; //NSLog(@"%@",encoded); NSString *varyingString1 = @"picture="; NSString *varyingString2 = urlPOST; NSString *post = [NSString stringWithFormat: @"%@%@", varyingString1, varyingString2]; NSLog(@"%@", post); //NSString *post […]

转换NSArray – > JSON – > NSData – > PHP服务器 – > JSON表示

我正在将NSDictionaries数组转换为JSON数据与以下… 创build我的数据… NSMutableArray *arrayOfDicts = [[NSMutableArray alloc] init]; for (int i = 0; i < 2; i++) { NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: @"MySong", @"title", @"MyArtist", @"artist", nil]; [arrayOfDicts addObject:dict]; } NSArray *info = [NSArray arrayWithArray:arrayOfDicts]; NSData* jsonData = [NSJSONSerialization dataWithJSONObject:info options:NSJSONWritingPrettyPrinted error:&error]; 然后发送像这样… NSURL *url = [NSURL URLWithString:@"http://www.mywebsite.com/index.php"]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request […]

MP4在直接访问时播放,而不是在iOS上通过PHP读取时播放

我使用PHP脚本来validationvideo请求之前,他们。 这个脚本按照预期在桌面上运行,使用Safari和Chrome。 但在iOS上,我得到一个打破的播放button。 我相信这个video是正确编码的iPhone / iPad,因为当我直接访问它,它按预期工作。 相关的PHP代码: $file_name = 'test-video.mp4'; $file_size = (string)(filesize($file_name)); header('Content-Type: video/mp4'); header('Content-Length: '.$file_size); readfile_chunked($file_name); exit; ( readfile_chunked()类似于readfile()但对于非常大的文件,可以在PHP手册页的注释中find: http : //php.net/manual/en/function.readfile.php 。无论如何, test-video.mp4只有~5MB,小于内存限制 – 在这种情况下,我实际上可以replace正常的readfile()并产生完全相同的行为。) 我直接访问test-video.mp4时得到的标题是: Accept-Ranges:bytes Connection:Keep-Alive Content-Length:5558749 Content-Type:video/mp4 Date:Sun, 27 Jun 2010 21:02:09 GMT Etag:"1c04757-54d1dd-489944c5a6400" Keep-Alive:timeout=10, max=30 Last-Modified:Tue, 22 Jun 2010 01:25:36 GMT Server:Apache/2.2.15 (CentOS) mod_ssl/2.2.15 0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635 […]

在iOS和PHP之间AESCrypt解密

我有一段时间搞清楚如何解密用NSData + AESCrypt.mencryption的string( 这里解释 ) 我一直在寻找其他一些线程,但是我只需要iDevice将一个string发送到一个PHP文件encryption,然后在PHP内部(它被存储到数据库中)解密。 此代码: NSString *encryptedString = [@"Hello" AES256EncryptWithKey:@"a16byteslongkey!"]; NSLog(@"The strign encrypted : %@",encryptedString); 返回encryption的string: 7opqbb7sEVNoXplyQv / X8g == 这里是我的解密PHP代码: function decrypt_data($data, $key) { return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key,$data,MCRYPT_MODE_ECB); } function unpadPKCS7($data, $blockSize) { $length = strlen ( $data ); if ($length > 0) { $first = substr ( $data, – 1 ); if […]

PHP Apple增强推送通知读取错误响应

在PHP中,如何在发送增强的推送通知时使用fread()来检查是否有错误响应? 我已经阅读了苹果的文档,通过谷歌几个模糊的post,和一些问题/答案在这里,但这仍然是非常混乱。 下面是我看到的: http : //developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html 从苹果增强推送通知读取错误与 iPhone iPhone推送通知 – 错误响应问题 我将在下面回答我自己的问题,基于以下事实:(1)我发现这是一个令人困惑的话题,(2)我必须将信息连同大量的反复试验结合起来, (3)这个博客文章说,这是鼓励: http : //blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/

GCM通知不会在iOS中处于后台模式时收到

我在我现有的应用程序中configuration了GCM,并在那里接收通知。 现在我面临两个问题:1)我没有收到通知当我退出应用程序或应用程序在后台。 2)我没有收到iphone的通知区域通知,只有当我的应用程序正在运行我只直接接收警报消息那里。 当我拉下通知区域时,我在xcode的控制台中看到这条消息: “无法连接到GCM:操作无法完成(com.google.gcm error 2001.)” 我的PHP文件在下面 <?php // Payload data you want to send to iOSdevice(s) // (it will be accessible via intent extras) $data = array( 'message' => 'Hello World!'); // The recipient registration tokens for this notification // http://developer.android.com/google/gcm/ $ids = array( 'kucy6xoUmx********eeRsla' ); // Send a GCM push sendGoogleCloudMessage( $data, […]