Using NSURLRequest to pass key-value pairs to PHP script with POST

后端 未结 6 2085
灰色年华
灰色年华 2021-01-31 20:51

I\'m fairly new to objective-c, and am looking to pass a number of key-value pairs to a PHP script using POST. I\'m using the following code but the data just doesn\'t seem to b

6条回答
  •  时光取名叫无心
    2021-01-31 21:14

    This line [request setHTTPBody:[NSData dataWithBytes:data length:[data count]]]; looks way wrong to me.

    I think you want: [request setAllHTTPHeaderFields:data];

    Secondly, you will find the Cocoa framework capitalizes the first letter of your field names before sending them (annoyingly). You might have to make some changes to cope with that.

提交回复
热议问题