Sending POST data from iphone over SSL HTTPS

前端 未结 4 1240
予麋鹿
予麋鹿 2020-11-30 17:13

Hai all,

In my iphone project i need to pass the user name and password to a web server,previously i pass data using GET method and used the url with GET format (eg:

4条回答
  •  死守一世寂寞
    2020-11-30 17:48

    You are sending the request as NSASCIIStringEncoding but looking for NSUTF8StringEncoding

    I'd set

    NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    

    and

    [request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    

    however, as Nikolai noted - this would be easier if we knew what the error was :-)

提交回复
热议问题