CRM

Sample code to call CRM methods

You have to create an XML to call a proper method. After creating the request XML you can use such kind of code.

$opts = array(	'http' => array(		'method'  => 'POST',		'header'  => array(			'Connection: close',			'Content-Type: text/xml; charset=utf-8',			'Content-Length: '.strlen($xml)		),		'content' => $xml	));$context = stream_context_create($opts);$response = file_get_contents("https://co3app.com/api/crm", false, $context);echo $response;

Every method will return with an XML response.

Methods for the CRM plugin

getContact

Get one contact’s details by ID. Define the ID in the contact_id tag.Sample request XML.

 <?xml version="1.0" encoding="utf-8"?> <command> <getContact> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> <contact_id>21</contact_id> </getContact> </command>

getContacts

Get all of the contacts’ IDs and names belogns to the CO3 account.Sample request XML

 <command> <getContacts> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> </getContacts> </command>

getHistoryTypes

Get the possible values of the contact history types.Sample request XML.

 <?xml version="1.0" encoding="utf-8"?> <command> <getHistoryTypes> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> </getHistoryTypes> </command>

getHistory

Get contact’s history by contact ID.Sample request XML.

 <?xml version="1.0" encoding="utf-8"?> <command> <getHistory> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> <contact_id>21</contact_id> </getHistory> </command>

setHistory

Create a new history element for the specified contact.Sample request XML.

<?xml version="1.0" encoding="utf-8"?> <command> <setHistory> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> <contact_id>21</contact_id> <contact_history_text><![CDATA[This is the text of the history...]]></contact_history_text> <contact_history_type>2</contact_history_type> </setHistory> </command>

setContact

Create a new contact.Sample request XML.

<?xml version="1.0" encoding="utf-8"?> <command> <setContact> <api_key><![CDATA[put-your-api-key-here]]></api_key> <session_key><![CDATA[put-your-session-key-here]]></session_key> <contact_id></contact_id> <!-- Leave blank if it is a new contact, or fill in if you like contact update --> <contact_type>0</contact_type> <!--0 = person, 1 = company --> <contact_prefix><![CDATA[Mr.]]></contact_prefix> <contact_firstname><![CDATA[John]]></contact_firstname> <contact_lastname><![CDATA[Doe]]></contact_lastname> <contact_firm><![CDATA[ACME Ltd.]]></contact_firm> <contact_address><![CDATA[1000 Coney Island Ave. Brooklyn NY 11230]]></contact_address> <contact_phone><![CDATA[+1302039960]]></contact_phone> <contact_phone2><![CDATA[+1302039999]]></contact_phone2> <contact_email><![CDATA[john.doe@email.com]]></contact_email> <contact_owner><![CDATA[username of the owner]]></contact_owner> <contact_job><![CDATA[Advisor]]></contact_job> <contact_fax><![CDATA[1238712948]]></contact_fax> <contact_postal_address><![CDATA[1071 Budapest, Damjanich u. 50.]]></contact_postal_address> <contact_importance>2</contact_importance> <contact_status><![CDATA[status from the list]]></contact_status> <contact_note><![CDATA[Some background notes]]></contact_note> <contact_categories><![CDATA[category from the possible values]]></contact_categories> <contact_account><![CDATA[11700001-00000000-25643570]]></contact_account> <contact_tax><![CDATA[10708589-2-20]]></contact_tax> <contact_url><![CDATA[http://google.com]]></contact_url> <contact_birthday><![CDATA[1984-03-29]]></contact_birthday> <contact_personal_id><![CDATA[345675DA]]></contact_personal_id> </setContact> </command>

Comments are closed.