Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用AFHTTPRequestOperationManager的AFNetworking发送EmailId或设备令牌作为参数_Ios_Objective C_Afnetworking 2 - Fatal编程技术网

Ios 如何使用AFHTTPRequestOperationManager的AFNetworking发送EmailId或设备令牌作为参数

Ios 如何使用AFHTTPRequestOperationManager的AFNetworking发送EmailId或设备令牌作为参数,ios,objective-c,afnetworking-2,Ios,Objective C,Afnetworking 2,我需要向服务器发送电子邮件ID以使用AFNetworking重置此电子邮件地址 SSAFRequest *afm= [[SSAFRequest alloc]init]; NSDictionary *params = @{@"email": @"a@b.com"}; [afm AfRequest_POST_Params:urlWithQuerystring urlWithQuerystring:urlWithQuerystring params:params :^(id JSON, NSError

我需要向服务器发送电子邮件ID以使用AFNetworking重置此电子邮件地址

SSAFRequest *afm= [[SSAFRequest alloc]init];
NSDictionary *params = @{@"email": @"a@b.com"};
[afm AfRequest_POST_Params:urlWithQuerystring urlWithQuerystring:urlWithQuerystring params:params :^(id JSON, NSError *error) {
    if(JSON!=Nil  && ![JSON isEqual:[[NSNull alloc]init]]) {


}];
这是我的网络代码:

-(void)AfRequest_POST_Params:(NSString *)baseUrl urlWithQuerystring:(NSString *)urlstring params:(NSDictionary *)parameters:(void (^)(id result, NSError *error))block {

NSLog(@"AfRequest_POST_Params ----%@ %@",baseUrl,urlstring);

AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager manager]initWithBaseURL:[NSURL URLWithString:baseUrl]];
manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];

[manager POST:baseUrl parameters:parameters
     success:^(AFHTTPRequestOperation *operation, id responseObject){
         NSLog(@"****Success****");
        block(responseObject,nil);

     }
     failure:^(AFHTTPRequestOperation *operation, NSError *error) {
         NSLog(@"Error: %@", error.localizedDescription);
         block(nil,error);

     }
 ];
}

但我不知道我的代码中缺少了什么。这就是我得到的错误:

<0x16d95210 SSLoginViewController.m:(821)> Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x16ec5cd0 {NSDebugDescription=Invalid value around character 0.}
Error Domain=NSCocoaErrorDomain code=3840“操作无法完成。(Cocoa错误3840)。“(字符0周围的值无效。)UserInfo=0x16ec5cd0{NSDebugDescription=字符0周围的值无效。}

请就此向我提出建议,提前谢谢。

当我发送的JSON参数格式不正确时,我出现了此错误。您将参数发送到哪里?我看到您正在将
Nil
传递到
POST:parameters:success:failure:
方法。我发送的参数正确,可能的问题是如何使用emailId,因为emailId在您调用的第一段代码中包含特殊字符
[afm AfRequest\u POST\u Params:urlWithQuerystring urlWithQuerystring:urlWithQuerystring Params:Params:^(id JSON,NSError*错误){
但是您已经发布了
-(void)AfRequest\u POST\u text的方法代码:(NSString*)baseUrl:
AfRequest\u POST\u Params是什么样子的?嘿,Flex,我编辑了代码,请检查我是否解决了这个问题,谢谢大家