php-api
php-api copied to clipboard
Update all values by email?
Is it possible to update all values to an existing contact based on email address? I would like to update lead score, star value, tags and properties in a single command, if possible.
Hi @mcpacific,
Yes it is possible with API, but need to careful while calling this API. Please follow the step mention below and condition -
1. Get Contact by email using below API
https://github.com/agilecrm/php-api#12-to-fetch-contact-data
$result = curl_wrap("contacts/search/email/[email protected]", null, "GET", "application/json"); $contact = json_decode($result, false, 512, JSON_BIGINT_AS_STRING);
2. Use setter method to set lead score, star value, and contact properties : $result = curl_wrap("contacts/search/email/[email protected]", null, "GET", "application/json"); $contact = json_decode($result, false, 512, JSON_BIGINT_AS_STRING);
$contact ->lead_score="80"; $contact ->star_value="4"; $contact ->tags=array("Player","Winner");
$contact -> properties = array( array( "name"=>"first_name", "value"=>"Ronaldo", "type"=>"SYSTEM" ), array( "name"=>"last_name", "value"=>"de Lima", "type"=>"SYSTEM" ) );
$contact_json = json_encode($contact);
$contactResult = curl_wrap("contacts", $contact_json, "PUT", "application/json");
print_r($contactResult );
3. Note Make sure that while settings contact properties you are setting all remaining contact properties too otherwise that data will be lost. So if your existing contact have first name, last name, email, address, custom fields then you have to send all this properties and not only first name, last name.
Please let us know in case need further information.
Thanks
This is great, and will speed up updates. I'll be sure to check fields to ensure no data is lost!
Thank you!!
Hi @graut and @mcpacific ,
with regard to Point #2 and #3, does that mean if my contact has many properties such as mailing address etc, I will have to include it in the setter method code, even if I'm not going to update those data? Thank you. :)