質問

I am using AFNetworking for api of my application

How to write the same request on AFNetworking

curl --data "login=test&pass=123456&email=test@test.com" http://somehost.com/api/register.php -X POST
役に立ちましたか?

解決

AFNetworking has fantastic documentation. I suggest you check it out.

Here's the link to the current docs to answer your question: http://cocoadocs.org/docsets/AFNetworking/2.2.1/Classes/AFHTTPSessionManager.html#//api/name/POST:parameters:success:failure:

The method in AFNetworking 2.2.1's AFHTTPSessionManager is - (NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void ( ^ ) ( NSURLSessionDataTask *task , id responseObject ))success failure:(void ( ^ ) ( NSURLSessionDataTask *task , NSError *error ))failure. Simply set URLString to your endpoint, implement your query string parameters as the parameters NSDictionary, and setup your success or error blocks as necessary.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top