문제

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