1
我使用AFNetworking將包含設備中聯繫人詳細信息的數組發佈到服務器。以下是我的代碼。無法使用AFNetworking將數組發佈到服務器
NSDictionary *parameters = @{@"UserContacts": contactsArray};//contactsArray is NSMutableArray
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager POST:baseUrl parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
NSLog(@"RESPONSE : %@",responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"Error: %@", error.localizedDescription);
}];
我回來的響應是
RESPONSE: 「失敗」
通知:未定義指數:在ÇUserContacts:\ XAMPP \ htdocs中\創建者\ PHP \控制器\ contactsync上線
在PHP .PHP代碼在下面給出
public function insertios(){
if(!isset($_REQUEST['UserContacts'])){
echo json_encode('failed');
$contact = $_REQUEST['UserContacts'];
echo $contact;
}else{
echo json_encode('Success');
}
}
請告訴我我哪裏出錯了。