Tag: 发布

如何从iOS应用程序使用POST发送NSData?

NSData *imageData = UIImagePNGRepresentation(image); 如何使用POST发送imageData?

从iOS发送多部分POST并读取PHP $ _POST中的参数?

我试图从iPhone / iPad发送一个多行文章到一个PHP服务,问题是,由于某种原因,POST内容types似乎是应用程序/ x-www-form-urlenconded,(我发现这个使用Wireshark) 这实际上是Wireshark POST数据包捕获的一个片段: **Content-Type: application/x-www-form-urlencoded\r\n** Content-Length: 324\r\n [Content length: 324] Connection: keep-alive\r\n \r\n [Full request URI: http://my.server.com/mobile/tools/authentication] Line-based text data: application/x-www-form-urlencoded –0xKhTmLbOuNdArY\r\n Content-Disposition: form-data; name="login"\r\n \r\n hello@hello.com\r\n –0xKhTmLbOuNdArY\r\n Content-Disposition: form-data; name="password"\r\n \r\n somepassword\r\n –0xKhTmLbOuNdArY\r\n \r\n –0xKhTmLbOuNdArY–\r\n 问题是,在服务器我试图从这个POST请求读取login和密码variables,但这是不可能的,因为我认为php认为POST请求是x-www-form-urlencoded ,所以如果我设置authentication.php来做: <?php echo("<pre>") print_r($_POST) echo("</pre>") ?> 我得到这个: <pre>Array\n (\n [–0xKhTmLbOuNdArY\r\n Content-Disposition:_form-data;_name] => "login"\r\n \r\n hello@hello.com\r\n […]

用iPhone使用最新的FBConnect SDK发布到用户的Facebook墙上

我很难find任何FBConnect iPhone SDK的良好文档。 我有SDK设置为从用户获得权限,但做一个简单的职位是逃避我。 我只能findPHP web SDK的文档。 任何人都可以指向我的iPhone SDK的一些文档或让我知道如何使用最新的图FBConnect SDK发布到用户墙? 谢谢!

如何在HTTP POST中将多个参数发送到PHP服务器

我发送base64string到PHP服务器,它的工作正常。 现在我想发送另一个参数作为一个string。 任何人都可以告诉我什么代码需要添加在下面的代码。 下面的代码对单个参数有效。 我们如何修改它的多个参数? NSData *data = [UIImageJPEGRepresentation(imgeview.image,90) base64Encoding]; // Create your request string with parameter name as defined in PHP file NSString *myRequestString = [NSString stringWithFormat:@"question_image=%@",data]; myRequestString = [myRequestString stringByReplacingOccurrencesOfString: @"+" withString:@"%2B"]; // Create Data from request NSData *myRequestData = [NSData dataWithBytes:[myRequestString UTF8String] length:[myRequestString length]]; request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://192.168.0.101/Mobile_tutor/webservice/question_details.php"]]; // […]

如何使2个参数POST NSURLRequest?

我想添加2个参数给NSURLRequest 。 有没有办法或应该使用AFnetworking?

Phonegap的iOS 5.1和localStorage

我正在使用localstorage为我的应用程序保存一个值,与PhoneGap一起工作,但是当苹果发布新的iOS 5.1时,我的应用程序现在不保存该值。 有谁知道如何解决这个问题? 非常感谢你!!! 编辑:我把我使用的代码: window.localStorage.setItem("login", $('#login').val()); 我用它来保存价值,我用它来读取值: function onDeviceReady() { var login = window.localStorage.getItem("login"); if (login != null) { $('#login').val(login); } } 但是,当我closures应用程序,值不会被保存。

POST请求不考虑NSMutableURLRequest超时间隔

我有以下问题。 在使用HTTP方法POST的NSMutableURLRequest ,为连接设置的超时间隔被忽略。 如果互联网连接有问题(代理错误,错误的DNS),约2-4分钟后url请求失败,但NSLocalizedDescription = "timed out";不会NSLocalizedDescription = "timed out"; NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1001 UserInfo=0x139580 "The request timed out. 如果使用的http方法是GET它工作正常。 通过https连接是async 。 NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setTimeoutInterval:10]; //Set the request method to post [request setHTTPMethod:@"POST"]; if (body != nil) { [request setHTTPBody:body]; } // Add general parameters […]

NSURLConnection sendAsynchronousRequest无法从闭包中获取variables

我试图从一个PHP页面使用POST获取简单的文本响应。 我有以下代码: func post(url: String, info: String) -> String { var URL: NSURL = NSURL(string: url)! var request:NSMutableURLRequest = NSMutableURLRequest(URL:URL) var output = "Nothing Returned"; request.HTTPMethod = "POST"; var bodyData = info; request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding); NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()){ response, data, error in output = (NSString(data: data, encoding: NSUTF8StringEncoding))! } return output } 虽然这个代码不会抛出任何错误,但是当我这样打电话给它时: println(post(url, info: […]

afnetworking 3.0迁移:如何使用标题和HTTP正文进行POST

我试图做一个POST请求有HTTPHeader字段和HTTP正文的YouTube的API。 以前在AFNetworking 2.0版中,我曾经这样做过, NSDictionary *parameters = @{@"snippet": @{@"textOriginal":self.commentToPost.text,@"parentId":self.commentReplyingTo.commentId}}; NSString *url = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/comments?part=snippet&access_token=%@",[[LoginSingleton sharedInstance] getaccesstoken]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; // And finally, add it to HTTP body and job done. [request setHTTPBody:[jsonString […]

我如何pipe理构buildiPhone应用程序的精简版和付费版本?

我开始想要考虑构build我的iPhone应用程序的精简版。 我在网上发现了一些关于这个过程的内容,即: http://developer.apple.com/tools/XCode/XCodeprojects.html http://www.pacificspirit.com/blog/2009/01/27/building_for_multiple_iphone_targets_in_xcode 我特别感兴趣的是简化pipe理哪些文件包含在我的应用程序的不同版本中的过程,因为我不断修改和增强付费版本。