2017-06-06 53 views
0

我正在使用PHP SDK作爲常量聯繫人插件。我想將聯繫人從一個列表移到另一個列表。我試過下面的代碼,它會產生BAD響應錯誤。如何使用PHP API將聯繫人從一個列表移動到另一個列表

$action = "Updating Contact"; 
$contact = $response->results[0]; 
foreach ($contact->lists as $key => $value) { 
    unset($contact->lists[$key]); 
} 
$cc->contactService->updateContact(WPYog_ACCESS_TOKEN, $contact,true); 
$contact->addList((string)$_POST['list_id']); 
$contact->first_name = 'Sudhir'; 
$contact->status = 'ACTIVE'; 
$contact->email_addresses[0]->status = 'ACTIVE'; 
$contact->last_name = 'Pandey'; 
try { 
    $cc->contactService->updateContact(WPYog_ACCESS_TOKEN, $contact,true); 
}catch (CtctException $ex) { 
    var_dump($ex->getErrors()); 
} 

回答

0

我找到了答案。首先使用此取回記錄

$action = "Updating Contact"; 
$contact = $response->results[0]; 

// Now empty the list 
$contact->lists = array(); 
$contact->addList((string)$_POST['list_id']); 
$contact->first_name = 'Sudhir'; 
$contact->status = 'ACTIVE'; 
$contact->email_addresses[0]->status = 'ACTIVE'; 
$contact->last_name = 'Pandey'; 
try { 
    $cc->contactService->updateContact(WPYog_ACCESS_TOKEN, $contact,true); 
}catch (CtctException $ex) { 
    var_dump($ex->getErrors()); 
} 
相關問題