Project

General

Profile

CRM Contacts / Save

API CRM Contacts / Save se foloseste pentru a salva in CRM-ul While1 Voice contacte din surse externe.

API URL

https://[YOUR-PBX-URL]/api/crm-contacts

Datele se trasmit prin POST sau GET si trebuie sa fie de forma:

Array
(
    [action] => save
    [data] => Array
        (
            [0] => Array
                (
                    [properties] => Array
                        (
                            [remote_id] => ASDF1234
                            [id] => 
                            [crm_type_id] => 1
                            [name] => John Doe
                            [telephones] => Array
                                (
                                    [0] => 0700000001
                                    [1] => 0700000002
                                )

                            [title] => 
                            [email] => 
                            [website] => 
                            [priority] => 0
                            [direct_line] => 
                            [address] => 
                            [start_date] => 
                            [end_date] => 
                            [comments] => 
                            [status] => active
                        )

                    [custom_fields] => Array
                        (
                            [8] => Acme company
                            [9] => Array
                                (
                                    [0] => 22
                                )

                        )

                )

        )

    [api_hash] => 20b093246dac88454f390553e813aa0d
)

Parametrul action trebuie sa aiba valoarea save

Parametri:

  • data: Array cu contactele
  • data - properties: Array cu proprietatile standard ale fiecarui contact
  • data - custom_fields: Array cu custom-fields setate in CRM Config :: Custom fields ale fiecarui contact

Headere HTTP:

Content-Type: text/xml
Authorization: Bearer <token>

Exemplu generare parametri:

$params = array(
    'action' => 'save',
    'data' => array(
        'ASDF1234' => array(
            // Contact properties
            'properties' => array(
                'remote_id' => "ASDF1234", // your own CRM ID
                'id' => '', // will be matched by remote_id if left blank
                'crm_type_id' => 1, // ID from CRM Config :: Element types
                'name' => 'John Doe',
                'telephones' => array('0700000001', '0700000002'),
                'title' => null,
                'email' => null,
                'website' => null,
                'priority' => 0,
                'direct_line' => null,
                'address' => null,
                'start_date' => null,
                'end_date' => null,
                'comments' => null,
                'status' => 'active',
            ),
            // Custom fields (Keys are IDs from CRM Config :: Custom fields). If specified, will be deleted, if not, will be ignored
            'custom_fields' => array(
                8 => 'Acme company', // Company
                9 => array(22) // Department
            )
        )
    )
);

Exemplu generare hash:

$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash

Exemplu trimitere date:

$url = 'https://[YOUR-PBX-URL]/api/crm-contacts';
$token = 'your_api_token';
echo curlPost($url, http_build_query($params), array("Authorization: Bearer {$token}"));

Raspuns

In caz de succes:

{
    "has_error": false,
    "messages": [],
    "results": {
    "ASDF1234": {
        "id": 3,
        "remote_id": "ASDF1234" 
        }
    }
}

Sau in caz de eroare:

{

    "has_error": true,
    "messages": [
        "Error on Contact update (ASDF1234): Contact ID is required" 
    ],
    "pagination": [ ],
    "results": [ ]

}

Disponibil si in alte limbi: EN

Go to top