nsurlrequest

Can't Receive JSON Request Via HTTPS Due To Untrusted Certificate

旧城冷巷雨未停 提交于 2019-12-13 05:06:18
问题 I have been googling this problem for hours now, and I can't seem to find a solution. The last tutorial I followed was this tutorial explaining how I could send a JSON request over an untrusted SSL connection (in this case, a self-signed certificate). In short, the code I have tried so far is this one: This method checks if the token is valid with my web API: -(BOOL)linked { if([self token] == nil) { return NO; }else { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?token=%@

API POST method not saving data in sql server

岁酱吖の 提交于 2019-12-13 02:47:47
问题 Hi I'm new to iphone development, I'm currently working with a project where I have a screen, in which user should enter their details, like username and password. I googled and find out about NSURLConnection for GET/POST/DELETE. I can GET data by the below codes, NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"http://************/api/Users"]]; [request setHTTPMethod:@"GET"]; [request setValue:@"application/json;charset=UTF-8"

How to fix setAllowsAnyHTTPSCertificate private api use for Apple app submission?

♀尐吖头ヾ 提交于 2019-12-12 21:12:25
问题 I'm using the following code to send a user login to a server, but Apple says that I'm using a private API and will reject the app. How can I resolve this? would replacing with [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; [request setHTTPMethod:@"POST"]; be enough? @interface NSURLRequest (DummyInterface) + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host; + (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host; @end and my login code: // token

How to check if a file exists at particular URL?

橙三吉。 提交于 2019-12-12 19:06:54
问题 How do I check if a file exists on a web site? I am using NSURLConnection with my NSURLRequest and an NSMutableData object to store what comes back in the didReceiveData: delegate method. In the connectionDidFinishingLoading: method I then save the NSMutableData object to the file system. All good. Except: if the file does not exist at the website, my code still runs, gets data and saves a file. How can I check the file is there before I make download request? 回答1: Implement connection

NSURLRequest cache issue iOS 7

﹥>﹥吖頭↗ 提交于 2019-12-12 09:41:30
问题 in iOS 7 cachePolicy doesn't work, it just cache the downloaded json. //URLRequest NSString *url = [NSString stringWithFormat:@"http://www.semhora.com/jsonparser/categories/categories_%d_test.json", _categoriesIndex]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:60.0]; How can I disallow cache in iOS 7? 回答1: I encountered the same problem and I verified that setting cachePolicy = 0 instead of

Why the http post request body always wrapped by Optional text in the Swift app

删除回忆录丶 提交于 2019-12-12 05:12:45
问题 I am writing the swift code to send a http post request to the php server. But my php script always get the strange post body because the parameters are wrapped by the Option(), If I send parameters like "id=john&password=1234", the server will get Optional(id=john&password=1234). But this is not what I want because php cannot analyse the parameters in the normal way. I have no idea about what's going wrong here; var postString: String = "id=john&password=1111" request.HTTPBody = (postString

How to send image data to server? (I already have a sample page)

我的梦境 提交于 2019-12-12 05:08:56
问题 How to send image data to server? (I already have a sample page) Sample Page html Source Code <form action="/uploadfile.html" method="post" enctype="multipart/form-data" onSubmit="return validate();"> <fieldset><legend>Upload File</legend> <table> <tr> <td><input name="fileData" id="image" type="file" /></td> </tr> <tr> <td><br /> </td> <td><input type="submit" value="Upload" /></td> </tr> </table> </fieldset> </form> It works fine on web page. (File Name: 1234.png) This server check file

Body of NSMutableRequest consisting of base64encodeString gets truncated while sending as a string

橙三吉。 提交于 2019-12-12 03:09:01
问题 Recently, I am doing a NSUrlSession task to upload multiple images to the backend . I appended all the images in .png representation in an array. I converted the whole array into a base64 String format and tried to send the whole body as a string. Conversion of imageArray to String - let imageArrayData: NSData = NSKeyedArchiver.archivedDataWithRootObject(imageArray) let imageArrayBase64String = imageArrayData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) Here

iOS download file from a URL that will redirect to the file

不想你离开。 提交于 2019-12-12 02:55:57
问题 I've been trying for 2 days and cant figure this out. Basically I have a URL and I try to download the file that associate with it using ASIHTTPRequest, but the URL I have is not the link of the file itself, but that URL will redirect to the link of the actual file. I try to give that link to ASIHTTPRequest for download, but it didn't. SO I think I have to somehow get the redirected url and feed that to ASIHTTPRequest to download the file. How can I do this? Thanks all for reading :) 回答1: You

How do post Json and Image to server for ios

安稳与你 提交于 2019-12-12 02:30:06
问题 How do post Json and Image to server for ios? I know post Json Data & Image , but I don't know post Json and Image at the same time? Because I want to order, I need post user info and user image to server. 回答1: -(void)postMethod { NSString *urlString = [NSString stringWithFormat:@"http:********web-services/register_user.php?firstname=%@&lastname=%@&email=%@&password=%@&location=india&device=IPHONE",details.fname,details.lname,details.emailAddress,details.password]; UIImage *image=details.pic;