views:

87

answers:

1

I want to convert cURL command:

curl -F 'access=xxxx' \ -F 'message=Hello.' \ -F '[email protected]' \ https://example.com

to a NSURLRequest.

Can somebody please help me with this?

A: 

Hi,

If you want to create a request with POST data, I suggest you to use ASIHTTPRequest: http://allseeing-i.com/ASIHTTPRequest

It is quite powerful and easy to use, you should take a look at the ASIFormDataRequest class (see the How To Use section).

I've never used it for SSL connections though, but I'm pretty sure it's possible.

Jukurrpa
That helped a lot.
Minar
I am ASIHTTPRequest but I am not being able to upload the picture to Facebook.I use the following line of codeNSString *pngName = @"bubble";NSString *pngPath = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.png", pngName] ];[request setFile:pngPath forKey:@"picture"];I have checked that the file is there at the place I expect it to be. Can you please help?
Minar
Well hard to say with so few information. What is exactly the problem you have when uploading?Maybe posting some more code would be useful too. What is documentsDirectory?
Jukurrpa
This is the document directory:NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];NSString *pngName = @"bubble"; NSString *pngPath = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.png", pngName] ]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];[request setFile:pngPath forKey:@"picture"];//Tried this too//[request setPostValue:pngPath forKey:@"picture"];[request startSynchronous];Please help :)
Minar
Well these lines seem ok, so you should check every step: is pngPath correct? Don't you need to send more POST data? What does the request return (done, failed, status code...)?Maybe you should create a new question with your code properly formatted and give as much information as you can about what happens when you run it.
Jukurrpa