Nincs fiókja? Ingyenes regisztráció

CRM

Sample PHP code to call CRM methods

You have to create an XML or JSON to call a proper method. After creating the request XML or JSON 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 a response with the same format as the request was.

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>

Sample request JSON.

{
  "command": {
    "getContact": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here",
      "contact_id": 21
    }
  }
}

getContacts

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

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

Sample request JSON.

{
  "command": {
    "getContacts": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here"
    }
  }
}

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>

Sample request JSON.

{
  "command": {
    "getHistoryTypes": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here"
    }
  }
}

getContactList

Get multiple contact pages by a specific search term. Allows paging.

Parameters:

  • api_key (string): Key for the application.
  • session_key (string): Session key.
  • search_term (string): The term used for searching. Searches in multiple fields such as email, name, tax number, postal address, invoicing address, phone number, category, status or company name.
  • page (integer, optional): Page number for paging.

Sample request XML.

<?xml version="1.0" encoding="utf-8"?>
<command>
    <getContactList>
        <api_key><![CDATA[put-your-api-key-here]]></api_key>
        <session_key><![CDATA[put-your-session-key-here]]></session_key>
        <search_term><![CDATA[John Doe]]></search_term>
        <page>0</page>
    </getContactList>
</command>

Sample request JSON.

{
  "command": {
    "getContactList": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here",
      "search_term": "John Doe",
      "page": 0
    }
  }
}

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>

Sample request JSON.

{
  "command": {
    "getHistory": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here",
      "contact_id": 21
    }
  }
}

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>

Sample request JSON.

{
  "command": {
    "setHistory": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here",
      "contact_id": 21,
      "contact_history_text": "This is the text of the history...",
      "contact_history_type": 2
    }
  }
}

setContact

Create a new contact. You can send custom fields if you specified them before on the CRM / Settings / Custom fields page. 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[+130****9960]]></contact_phone>
        <contact_phone2><![CDATA[+130****9999]]></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_groupmember_tax><![CDATA[10708589-2-20]]></contact_groupmember_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>
        <contact_newsletter>0</contact_newsletter>
        <custom_fields> <!-- Only if you specified custom fileds on CRM / Settings / Custom fields page -->
            <text_example>AB1234567</text_example> <!-- Tag names have to be match with the specified custom fields' name -->
            <radiobutton_example>
                <node0>yes</node0>
            </radiobutton_example>
            <checkbox_example>
                <node0>0</node0>
                <node1>30</node1>
            </checkbox_example>
            <number_example>20</number_example>
        </custom_fields>
    </setContact>
</command>

Sample request JSON.

{
  "command": {
    "setContact": {
      "api_key": "put-your-api-key-here",
      "session_key": "put-your-session-key-here",
      "contact_id": null,
      "contact_type": 0,
      "contact_prefix": "Mr.",
      "contact_firstname": "John",
      "contact_lastname": "Doe",
      "contact_firm": "ACME Ltd.",
      "contact_address": "1000 Coney Island Ave. Brooklyn NY 11230",
      "contact_phone": "+130****9960",
      "contact_phone2": "+130****9999",
      "contact_email": "john.doe@email.com",
      "contact_owner": "username of the owner",
      "contact_job": "Advisor",
      "contact_fax": "1238712948",
      "contact_postal_address": "1071 Budapest, Damjanich u. 50.",
      "contact_importance": 2,
      "contact_status": "status from the list",
      "contact_note": "Some background notes",
      "contact_categories": "category from the possible values",
      "contact_account": "11700001-00000000-25643570",
      "contact_tax": "10708589-2-20",
      "contact_groupmember_tax": "10708589-2-20",
      "contact_url": "http://google.com",
      "contact_birthday": "1984-03-29",
      "contact_personal_id": "345675DA",
      "contact_newsletter": 0,
      "custom_fields": {
        "text_example": "AB1234567",
        "radiobutton_example": {
          "node0": "yes"
        },
        "checkbox_example": {
          "node0": 0,
          "node1": 30
        },
        "number_example": 20
      }
    }
  }
}