Simple http post example in Objective-C?

后端 未结 8 1466
谎友^
谎友^ 2020-11-28 01:32

I have a php webpage that requires a login (userid & password). I have the user enter the information into the app just fine.. but I need an example on how to do a POST

8条回答
  •  -上瘾入骨i
    2020-11-28 02:02

    ASIHTTPRequest makes network communication really easy

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request addPostValue:@"Ben" forKey:@"names"];
    [request addPostValue:@"George" forKey:@"names"];
    [request addFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photos"];
    [request addData:imageData withFileName:@"george.jpg" andContentType:@"image/jpeg" forKey:@"photos"];
    

提交回复
热议问题