通过 Afnetworking 从 api 获取数据时出现问题
geting issue while fatching data from api via Afnetworking
我正在使用 iOS
Objective-c
, AFNetworing
经理 POST
JSON
数据
这是我的代码,但没有给我数据。
我的代码:
NSString *strUrl2 = @"http://example.extension/admin/services/login.php";
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
[dataDict setValue:@"dipesh@gmail.com" forKey:@"email"];
[dataDict setValue:@"123456" forKey:@"password"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [[AFJSONRequestSerializer alloc] init];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", @"application/json",@"application/x-www-form-urlencoded",@"png/jpg" , nil];
[manager POST:strUrl2
parameters:dataDict
success:^(AFHTTPRequestOperation* operation, id responseObject){
NSLog(@"Response: %@", responseObject);
}
failure:^(AFHTTPRequestOperation* operation, NSError* error){
NSLog(@"Error: %@", error);
// Releasing the semaphore to end the process from waiting state.
}];`
Not getting actual response.
正在获取响应:
{
login = {
message = "Please fill all required parameters";
status = failure;
};
}
注:
此 Web 服务适用于 postMan 和 android.
NSString *strUrl2 = @"http://fitgritapp.com/admin/services/login.php";
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
[dataDict setValue:@"dipesh@gmail.com" forKey:@"email"];
[dataDict setValue:@"123456" forKey:@"password"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:strUrl2 parameters:dataDict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
试试这个
login = {
message = "";
status = success;
user = {
"created_on" = "2017-01-18 12:26:01";
email = "dipesh@gmail.com";
"facebook_id" = "";
"first_name" = Dipesh;
id = 4;
"is_active" = 1;
"last_name" = Sisodiya;
password = 123456;
"password_reset_token" = "";
"updated_on" = "0000-00-00 00:00:00";
};
};
我正在使用 iOS
Objective-c
, AFNetworing
经理 POST
JSON
数据
这是我的代码,但没有给我数据。
我的代码:
NSString *strUrl2 = @"http://example.extension/admin/services/login.php";
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
[dataDict setValue:@"dipesh@gmail.com" forKey:@"email"];
[dataDict setValue:@"123456" forKey:@"password"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [[AFJSONRequestSerializer alloc] init];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", @"application/json",@"application/x-www-form-urlencoded",@"png/jpg" , nil];
[manager POST:strUrl2
parameters:dataDict
success:^(AFHTTPRequestOperation* operation, id responseObject){
NSLog(@"Response: %@", responseObject);
}
failure:^(AFHTTPRequestOperation* operation, NSError* error){
NSLog(@"Error: %@", error);
// Releasing the semaphore to end the process from waiting state.
}];`
Not getting actual response.
正在获取响应:
{
login = {
message = "Please fill all required parameters";
status = failure;
};
}
注: 此 Web 服务适用于 postMan 和 android.
NSString *strUrl2 = @"http://fitgritapp.com/admin/services/login.php";
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
[dataDict setValue:@"dipesh@gmail.com" forKey:@"email"];
[dataDict setValue:@"123456" forKey:@"password"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:strUrl2 parameters:dataDict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
试试这个
login = {
message = "";
status = success;
user = {
"created_on" = "2017-01-18 12:26:01";
email = "dipesh@gmail.com";
"facebook_id" = "";
"first_name" = Dipesh;
id = 4;
"is_active" = 1;
"last_name" = Sisodiya;
password = 123456;
"password_reset_token" = "";
"updated_on" = "0000-00-00 00:00:00";
};
};