API Contacts – TecArt-CRM Developer-Wiki

API Contacts

Aus TecArt-CRM Developer-Wiki

Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

Hinweis

API Klassen und deren Funktionen können nur mit CRM System mit Version >= 3.2 genutzt werden

Methods

addContact

Syntax:

 int addContact( array $contact ) 


Beschreibung:

Gibt eine contact id zurück.

Wirft eine CRMException im Fehlerfall.

$contact ist ein assoziatives Array.

Eigenschaften von $contact array:

Type(Length)      Eigenschaft             Beschreibung
-------------------------------------------------------------------
string(128)       $company             Firma
string(255)       $department          Abteilung
string(100)       $street              Adresse
string(20)        $postcode            Postleitzahl 
string(100)       $city                Stadt
string(255)       $email               E-Mail 
string(50)        $phone               Telefon
string(50)        $fax                 Fax
string(100)       $region              Region 
string(255)       $country             Land
string(255)       $acc_holder          Kontoinhaber
string(20)        $acc_nr              Kontonummer
string(20)        $bankcode            Bankleitzahl
string(255)       $bankname            Name der Bank 
string(100)       $swift               BIC/SWIFT  
string(100)       $iban                IBAN 
string(255)       $branch              Branchen, Format: Branch1:Branch2: ... 
string(255)       $category            Kategorien, Format: Category1:Category2: ... 
string(50)        $code                Code für Schnellsuche
string(65535)     $notes               Notizen
string(50)        $number              Nummer
string(255)       $superior            Superior, Format: Contact-Id:Person-Id 
string(255)       $type                Typ 
int               $userid              Verantwortlich 
string(50)        $ustnr               Steuernummer
string(255)       $website             Website
string(64)        $password            Passwort // seit CRM V3.1.2291
string(255)       $user27              Benutzerdefiniertes Feld Nr. 27
string(255)       $user28              Benutzerdefiniertes Feld Nr. 28
   :                 :                          :
string(255)       $user81              Benutzerdefiniertes Feld Nr. 81


Beispiel:

<?php
 
try {
    $contact = array('company'     => 'API Test-Company',
                 'department'  => 'Development',
                 'street'      => 'FischereiMarkt 5',
                 'postcode'    => '99084',
                 'city'        => 'Erfurt',
                 'region'      => utf8_encode('Thüringen'),
                 'country'     => 'Deutschland',
                 'email'       => 'info@xatec.de',
                 'phone'       => '+49 361 3801001',
                 'fax'         => '+49 361 3801000',
                 'notes'       => 'This is a WebServiceTest',
                 'number'      => '',
                 'website'     => 'http://www.xatec.de',
                 'acc_holder'  => 'Christian Friebel - Xatec',
                 'acc_nr'      => '1234567890',
                 'bankcode'    => '82070024',
                 'bankname'    => 'Deutsche Bank 24',
                 'swift'       => 'DEUTDEDBERF',
                 'iban'        => 'DE3459084359048594',
                 'category'    => 'Kunde:Lieferant',
                 'branch'      => 'Industrie:IT/Computer',
                 'userid'      => 5,
                 'code'        => '',
                 'type'        => utf8_encode('geschäftlich'),
                 'superior'    => '',
                 'ustnr'       => '',
                 'user27'      => 'Test 27',
                 'user28'      => 'Test 28',
                 'user29'      => 'Test 29',
                 'user30'      => 'Test 30');
 
    $crmapi_contacts = crmapi::contacts();
    $contact_id      = $crmapi_contacts->addContact($contact);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $contact_id;
?>

changeContact

Syntax:

 int changeContact( array $contact ) 


Beschreibung:

Gibt eine contact_id zurück.

Wirft eine CRMException im Fehlerfall.

Eigenschaften von $contact array: die gleichen wie von #addContact


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $contact = array('id'    => 1234,
         	     'email' => 'xray@tecart.de');
 
    $contact_id = $crmapi_contacts->changeContact($contact);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $contact_id;
?>

addPerson

Syntax:

 int addPerson( array $person ) 


Beschreibung:

Fügt eine Person zu einem existierenden Kontakt hinzu.

Gibt eine person_id zurück.

Wirft eine CRMException im Fehlerfall.


$person ist ein assoziatives Array.


Properties:

Type(Length)      Eigenschaft             Beschreibung
-------------------------------------------------------------------

int               $cid                 Contact-Id 

string(50)        $salutation          Anrede 
string(100)       $firstname           Vorname 
string(100)       $lastname            Nachname 
int               $birthday            Geburtstag als Unix-Timestamp (kann negativ sein) 
string(100)       $city                Stadt
string(100)       $country             Land 
string(255)       $email               E-Mail 
string(100)       $fax                 Faxnummer 
string(100)       $mobile              Mobilnummer
string(65535)     $notes               Notizen
string(50)        $number              Nr.
string(100)       $phone               Telefon 
string(100)       $position            Position z.B. CEO 
string(100)       $postcode            Postleitzahl
string(100)       $region              Region
string(100)       $street              Addresse 
string(255)       $type                Typ
 
string(255)       $user18              Benutzerdefiniertes Feld Nr. 18
string(255)       $user19              Benutzerdefiniertes Feld Nr. 19
   :                 :                            :
string(255)       $user65              Benutzerdefiniertes Feld Nr. 65 


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $person = array('cid'        => $contact_id,
		    'salutation' => 'Herr',
		    'firstname'  => 'Christian',
		    'lastname'   => 'Friebel',
		    'phone'      => '+49 361 3801001');
 
 
    $crmapi_contacts = crmapi::contacts();
    $person_id       = $crmapi_contacts->addPerson($person);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $person_id;
?>

changePerson

Syntax:

 int changePerson( array $person )


Beschreibung:

Ändert eine existierende Person.

Gibt eine person_id zurück.

Wirft eine CRMException im Fehlerfall.

Eigenschaften: die gleichen wie für #addPerson

Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $person = array('id'         => '123',
                    'position'   => 'CEO',
		    'phone'      => '123456');
 
    $crmapi_contacts = crmapi::contacts();
    $person_id       = $crmapi_contacts->changePerson($person);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $person_id;
?>

getContactIds

Syntax:

 array getContactIds( int $timestamp ) 


Beschreibung:

Gibt ein Array mit contact ids von Kontakten zurück, die seit timestamp geändert wurden.

Hinweis: Es werden nur Kontakte zurückgegeben, für welche der authentifizierte Nutzer Leseberechtigungen hat.


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
    $contact_ids = $crmapi_contacts->getContactIds(time() - 86400);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $contact_id as $id ) {
    echo $id . "<br/>\n";
}
?>

countContacts

Syntax:

 int countContacts( ) 


Beschreibung:

Gibt die Gesamtanzahl der Kontakte zurück.

Wirft eine CRMException im Fehlerfall.

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
    $contact_count = $crmapi_contacts->countContacts();
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $contact_count;
?>

countPersons

Syntax:

 int countPersons( ) 


Beschreibung:

Gibt die Gesamtanzahl der Personen zurück.

Wirft eine CRMException im Fehlerfall.

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
    $person_count = $crmapi_contacts->countPersons();
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $person_count;
?>

searchContacts

Syntax:

 array searchContacts( string $search, string $branch, string $category, int $count ) 


Beschreibung:

Gibt ein Array mit $contact results zurück.

Wirft eine CRMException im Fehlerfall.

$search ist ein freier Suchtext.

$branch ist die Branche des Kontakts, deaktiviert wenn auf -1 gesetzt

$category ist die Kategorie des Kontakts, deaktiviert wenn auf -1 gesetzt

$count ist die maximale Anzahl an Kontakten, die zurückgegeben werden soll.


Eigenschaften der zurückgegebenen Array:

die gleichen wie für #getSingleContact


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $result = $crmapi_contacts->searchContacts("tecart", -1, -1, 20);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($result as $cid => $contact) {
    echo "{$cid}, {$contact['lastname']}, {$contact['firstname']}, {$contact['company']}<br/>\n";
}
?>

searchContact

Syntax:

 array searchContact( array $items, int $count, int $offset, boolean $full_search, string $sort_name, boolean $or, array $get_fields ) 


Beschreibung:

Gibt ein Array mit contact ids, oder ganze Kontaktinformation zurück.

$items ist ein assoziatives Array, bei dem der key das Feld zum Suchen und der value der Suchstring ist. Sie können ein %-Zeichen am Anfang und/oder Ende der Zeichenfolge als Platzhalter verwenden.

$count ist die maximale Anzahl an Ids, die zurückgegeben wird.

$offset ist die Offset Position der Ergebnisse, die zurückgegeben werden sollen.

$full_search : Ist full_search auf true gesetzt, werden die vollständige Info der Kontakte (nicht nur IDs) zurückgegeben .

$sort_name ist die Sortierung, wie die Kontaktnamen sortiert werden sollen.

Nur mit CRM Version >= 3.4.5223 geht es mit folgenden Parameters

$or ist der SQL-Operator. Ist or auf true gesetzt, werden die Suchbegriffe mit OR verknüpft.

$get_fields is ein Array mit Felder, die zurückgegeben werden sollen. Wenn dieses Parameter nicht gesetzt ist, werden alle Felder wie für #getSingleContact zurück geliefert.


Beispiel 1: nur Kontakt ID zurück

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $search = array( 'company'  => 'tec%',
	             'city'     => '%furt%');
 
    $contact_ids  = $crmapi_contacts->searchContact($search, 10, 0);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contact_ids as $contact_id) {
    echo "Id: $contact_id<br/>\n";
}
?>


Beispiel 2: ganze Konaktinformation zurück

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $search = array( 'company'  => 'tec%',
	             'city'     => '%furt%');
 
    // Get the first 10 contacts with full contacts information, the result is sorted ascending by company name
    $contacts  = $crmapi_contacts->searchContact($search, 10, 0, true, 'ASC');
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contacts as $contact) {
    echo "Name: $contact['company'] <br/>\n";
    echo "Ort: $contact['city'] <br/>\n";
}
?>


Beispiel 3: Komplexe Suche

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Example 1: Get the first 10 contacts with company name like "tecart" OR like "crm" OR like "groupware"
    $search = array( 'company'  => array('tecart', 'crm', 'groupware') );
 
    $contacts  = $crmapi_contacts->searchContact($search, 10, 0, true, 'ASC');
 
 
    // Example 2: Get the first 10 contacts with company name like "tecart" OR like "crm" AND city like "erfurt"
    $search = array( 'company'  => array('tecart', 'crm'),
                     'city'     => 'erfurt' );
 
    $contacts  = $crmapi_contacts->searchContact($search, 10, 0, true, 'ASC');
 
 
    // Example 3: Get the first 10 contacts with company name like "tecart" OR city like "erfurt"
    $search = array( 'company'  => 'tecart',
                     'city'     => 'erfurt' );
 
    $contacts  = $crmapi_contacts->searchContact($search, 10, 0, true, 'ASC', true);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contacts as $contact) {
    echo "Name: $contact['company'] <br/>\n";
    echo "Ort: $contact['city'] <br/>\n";
}
?>


Beispiel 4: Hole nur bestimmte Felder

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get the first 10 contacts with name LIKE 'TecArt'
    $search = array( 'company'  => 'TecArt');
 
    // Only company name and city are needed.
    $get_fields = array( 'company', 'city' );
 
    $contacts  = $crmapi_contacts->searchContact($search, 10, 0, true, 'ASC', false, $get_fields);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contacts as $contact) {
    echo "Name: $contact['company'] <br/>\n";
    echo "Ort: $contact['city'] <br/>\n";
}
?>

getContact

Syntax:

 array getContact( int|string $cid, int $pid ) 


Beschreibung:

Gibt ein assoziatives $contact array zurück.

Wirft eine CRMException im Fehlerfall.

$cid ist die Contact-Id.

$pid ist die Person-Id, gibt keine Personendaten zurück, wenn auf 0

Hinweis: Sie können die Contact-Id als Integer oder String im Format 'contact_id:person_id' geben


Eigenschaften der zurückgegebenen contact:

Type(Length)      Eigenschaft             Beschreibung
-------------------------------------------------------------------
int               $cid                 Contact-Id 
string(128)       $contact_company     Kontakt Unternehmen
string(255)       $contact_department  Kontakt Abteilung
string(100)       $contact_street      Kontakt Addresse
string(20)        $contact_postcode    Kontakt Postleitzahl 
string(100)       $contact_city        Kontakt Stadt
string(255)       $contact_email       Kontakt E-Mail 
string(50)        $contact_phone       Kontakt Telefon 
string(50)        $contact_fax         Kontakt Fax 
string(100)       $contact_region      Kontakt Region 
string(255)       $contact_country     Kontakt Land
string(255)       $contact_acc_holder  Kontakt Kontoinhaber
string(20)        $contact_acc_nr      Kontakt Kontonummer
string(20)        $contact_bankcode    Kontakt Bankleitzahl
string(255)       $contact_bankname    Kontakt Name der Bank 
string(100)       $contact_swift       Kontakt BIC/SWIFT  
string(100)       $contact_iban        Kontakt IBAN 
string(255)       $contact_branch      Kontakt Branchen, Format: Branch1:Branch2: ... 
string(255)       $contact_category    Kontakt Kategorien, Format: Category1:Category2: ... 
string(50)        $contact_code        Kontakt Code für die Schnellsuche
string(65535)     $contact_notes       Kontakt Notizen
string(50)        $contact_number      Kontakt Nummer
string(255)       $contact_superior    Kontakt Superior, Format: Contact-Id:Person-Id 
string(255)       $contact_type        Kontakt Typ 
int               $contact_userid      Kontakt Verantwortlich 
string(50)        $contact_ustnr       Kontakt Steuernummer
string(255)       $contact_website     Kontakt Website

int               $contact_chgtime     Unix-Timestamp der letzten Kontaktänderung 
int               $contact_chguser     Userid der letzten  Kontaktänderung
int               $contact_createtime  Unix-Timestamp der Kontakterstellung
int               $contact_createuser  Userid der Kontakterstellung
 
int               $pid                 Person-Id 
string(50)        $person_salutation   Person Anrede
string(100)       $person_firstname    Person Vorname 
string(100)       $person_lastname     Person Nachname 
int               $person_birthday     Person Geburtstag als Unix-Timestamp (kann negativ sein) 
string(100)       $person_city         Person Stadt
string(100)       $person_country      Person Land 
string(255)       $person_email        Person E-Mail 
string(100)       $person_fax          Person Faxnummer 
string(100)       $person_mobile       Person Mobilnumber
string(65535)     $person_notes        Person Notizen
string(50)        $person_number       Person Nr.
string(100)       $person_phone        Person Telefon 
string(100)       $person_position     Person Position z.B. CEO 
string(100)       $person_postcode     Person Postleitzahl
string(100)       $person_region       Person Region
string(100)       $person_street       Person Addresse
string(255)       $person_type         Person Typ
 
int               $person_chgtime      Unix-Timestamp der letzten Personenänderung
int               $person_chguser      Userid der letzten Personenänderung
int               $person_createtime   Unix-Timestamp der Personenerstellung
int               $person_createuser   Userid der Personenerstellung


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $contact	 = $crmapi_contacts->getContact("13:37");
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contact as $key => $val) {
    echo "$key => $val<br/>\n";
}
?>

getSingleContact

Syntax:

 array getSingleContact( int $cid, boolean $format ) 


Beschreibung:

Gibt ein Array von contact arrays mit nur einem Element zurück.

Wirft eine CRMException im Fehlerfall.

$cid ist die Contact-Id.

Mit der Version (>=3.4.4827) gibt es eine Möglichkeit, die Daten als formatiert zurück zu haben, indem das Param $format auf true gesetzt ist.

Eigenschaften der zurückgegebenen contact:

Type(Length)      Eigenschaft             Beschreibung
-------------------------------------------------------------------
int               $cid                 Contact-Id 
string(128)       $company             Unternehmen
string(255)       $department          Abteilung
string(100)       $street              Addresse
string(20)        $postcode            Postleitzahl 
string(100)       $city                Stadt
string(255)       $email               E-Mail 
string(50)        $phone               Telefon
string(50)        $fax                 Fax
string(100)       $region              Region 
string(255)       $country             Land
string(255)       $acc_holder          Kontoinhaber
string(20)        $acc_nr              Kontonummer
string(20)        $bankcode            Bankleitzahl
string(255)       $bankname            Name der Bank 
string(100)       $swift               BIC/SWIFT  
string(100)       $iban                IBAN 
string(255)       $branch              Branchen, Format: Branch1:Branch2: ... 
string(255)       $category            Kategorien, Format: Category1:Category2: ... 
string(50)        $code                Code für die Schnellsuche 
string(65535)     $notes               Notizen 
string(50)        $number              Nr.
string(255)       $superior            Superior, Format: Contact-Id:Person-Id 
string(255)       $type                Typ 
int               $userid              Verantwortlich 
string(50)        $ustnr               Steuernummer
string(255)       $website             Website

int               $chgtime             Unix-Timestamp der letzten Kontaktänderung 
int               $chguser             Userid der letzten Kontaktänderung
int               $createtime          Unix-Timestamp der Kontakterstellung 
int               $createuser          Userid der Kontakterstellung 

string(255)       $user27              Benutzerdefiniertes Feld Nr. 27
string(255)       $user28              Benutzerdefiniertes Feld Nr. 28
   :                 :                          :
string(255)       $user81              Benutzerdefiniertes Feld Nr. 81


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $contact  = $crmapi_contacts->getSingleContact(15);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contact as $key => $val) {
    echo "$key => $val<br/>\n";
}
?>

getSinglePerson

Syntax:

 array getSinglePerson( int $pid, boolean $format ) 


Beschreibung:

Gibt ein Array mit person arrays mit nur einem Element zurück.

Wirft eine CRMException im Fehlerfall.

$pid ist die person id

Mit der Version (>=3.4.4827) gibt es eine Möglichkeit, die Daten als formatiert zurück zu haben, indem das Param $format auf true gesetzt ist.

Eigenschaften der zurückgegebenen array:

Type(Length)      Eigenschaft             Beschreibung
-------------------------------------------------------------------

int               $pid                 Person-Id 
int               $cid                 Contact-Id 

string(50)        $salutation          Anrede 
string(100)       $firstname           Vorname 
string(100)       $lastname            Nachname 
int               $birthday            Geburtstag als Unix-Timestamp (kann negativ sein) 
string(100)       $city                Stadt
string(100)       $country             Land 
string(255)       $email               E-Mail 
string(100)       $fax                 Faxnummer 
string(100)       $mobile              Mobilnumber
string(65535)     $notes               Notizen
string(50)        $number              Nr. 
string(100)       $phone               Telefon 
string(100)       $position            Position z.B. CEO 
string(100)       $postcode            Postleitzahl
string(100)       $region              Region
string(100)       $street              Addresse 
string(255)       $type                Typ
 
int               $chgtime             Unix-Timestamp der letzten Personenänderung 
int               $chguser             Userid der letzten Personenänderung 
int               $createtime          Unix-Timestamp der Personenerstellung
int               $createuser          Userid der Personenerstellung

string(255)       $user18              Benutzerdefiniertes Feld Nr. 18
string(255)       $user19              Benutzerdefiniertes Feld Nr. 19
   :                 :                            :
string(255)       $user65              Benutzerdefiniertes Feld Nr. 65 


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $person = $crmapi_contacts->getSinglePerson(37);
 
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contact as $key => $val) {
    echo "$key => $val<br/>\n";
}
 
?>

searchPersons

(CRM >= 3.4.5223)

Syntax:

 array searchPersons( array $items, int $count, int $offset, string $sort_name, boolean $or, array $get_fields ) 


Beschreibung:

Gibt ein Array mit Personinformation zurück.

$items ist ein assoziatives Array, bei dem der key das Feld zum Suchen und der value der Suchstring ist. Sie können ein %-Zeichen am Anfang und/oder Ende der Zeichenfolge als Platzhalter verwenden.

$count ist die maximale Anzahl an Ids, die zurückgegeben wird.

$offset ist die Offset Position der Ergebnisse, die zurückgegeben werden sollen.

$sort_name ist die Sortierung, wie die Nachname sortiert werden sollen.

$or ist der SQL-Operator. Ist or auf true gesetzt, werden die Suchbegriffe mit OR verknüpft.

$get_fields is ein Array mit Felder, die zurückgegeben werden sollen. Wenn dieses Parameter nicht gesetzt ist, werden alle Felder wie unten geschrieben zurück geliefert.


Eigenschaften des zurückgegebenen Array: die gleichen wie für #getSinglePerson mit dem zusätzlichen Variable company

Type(Length)      Eigenschaft            Beschreibung
-------------------------------------------------------------------

array             $company               Information der Firma


Eigenschaften des $company Array:

die gleichen wie für #getContact


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get the first 10 Persons with firstname like 'John' AND lastname like 'Smith'
    $search = array( 'firstname'  => 'John',
	             'lastname'   => 'Smith');
 
    $persons  = $crmapi_contacts->searchPersons($search, 10, 0, 'ASC');
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($persons as $person) {
    echo 'Name: '. $person['firstname'] . ' ' . $person['lastname'] ."<br>";
    echo 'Firma: ' . $person['company']['name'] ."<br>";
    echo '<br>';
}
 
?>


Beispiel 2: Komplexe Suche

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get the first 10 Persons with firstname like 'John' OR like 'Peter' OR like 'David'
    $search = array( 'firstname'  => array('John', 'Peter', 'David') );
 
    $persons  = $crmapi_contacts->searchPersons($search, 10, 0, 'ASC');
 
 
    // Get the first 10 Persons with firstname like 'John' AND lastname like 'Smith'
    $search = array( 'firstname'  => 'John',
                     'lastname'   => 'Smith' );
 
    $persons  = $crmapi_contacts->searchPersons($search, 10, 0, 'ASC');
 
 
    // Get the first 10 Persons with firstname like 'John OR lastname like 'Smith'
    $search = array( 'firstname'  => 'John',
                     'lastname'   => 'Smith' );
 
    $persons  = $crmapi_contacts->searchPersons($search, 10, 0, 'ASC', true);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($persons as $person) {
    echo 'Name: '. $person['firstname'] . ' ' . $person['lastname'] ."<br>";
    echo 'Firma: ' . $person['company']['name'] ."<br>";
    echo '<br>';
}
?>


Beispiel 3: Nur bestimmte Felder holen

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get the first 10 Persons with firstname like 'John' 
    $search = array( 'firstname' => 'John' );
 
    // Need only fields 'firstname' and 'lastname' and Array with company's information back.
    $get_fields = array( 'firstname', 'lastname', 'company' );
 
    $persons  = $crmapi_contacts->searchPersons($search, 10, 0, 'ASC', false, $get_fields);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($persons as $person) {
    echo 'Name: '. $person['firstname'] . ' ' . $person['lastname'] ."<br>";
    echo 'Firma: ' . $person['company']['name'] ."<br>";
    echo '<br>';
}
?>

getChangedContacts

Syntax:

 array getChangedContacts( int $timestamp ) 


Beschreibung:

Gibt ein Array mit Kontakten zurück, die seit timestamp geändert wurden.

Wirft eine CRMException im Fehlerfall.

Hinweis: Es werden nur Kontakte zurückgegeben, für welche der authentifizierte Nutzer Leseberechtigungen hat.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get contacts, which have been changed since the last 10 days.
    $contacts  = $crmapi_contacts->getChangedContacts(time()-3600*24*10);	
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contacts as $contact) {
    foreach($contact as $key => $val) {
        echo "$key => $val<br/>\n";
    }
}
?>

getChangedContactsLimit

Syntax:

 array getChangedContactsLimit( int $timestamp, int $count, int $offset ) 


Beschreibung:

Gibt ein Array mit Kontakten zurück, die seit timestamp geändert wurden.

Wirft eine CRMException im Fehlerfall.

$count ist die maximale Anzahl an Ergebnissen, die zurückgegeben werden soll. Wenn auf 0 gesetzt, wird ein Array ohne Größenlimit zurückgegeben.

$offset ist die Offset Position der Ergebnisse, die zurückgegeben werden sollen. Diese Variable hat keinen Effekt, wenn $count nicht gesetzt ist.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get only 10 contacts, which have been changed since the last 10 days.
    $contacts  = $crmapi_contacts->getChangedContacts(time()-3600*24*10, 10, 0);	
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($contacts as $contact) {
    foreach($contact as $key => $val) {
        echo "$key => $val<br/>\n";
    }
}
?>

getChangedPersons

Syntax:

 array crmapi_contacts->getChangedPersons( int $timestamp ) 


Beschreibung:

Gibt ein Array mit Personen zurück, die seit timestamp geändert wurden.

Wirft eine CRMException im Fehlerfall.

Hinweis: Es werden nur Kontakte zurückgegeben, für welche der authentifizierte Nutzer Leseberechtigungen hat.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get persons, which have been changed since the last 10 days.
    $persons = $crmapi_contacts->getChangedPersons(time()-3600*24*10);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($persons as $person) {
    foreach($person as $key => $val) {
        echo "$key => $val<br/>\n";
    }
}
?>

getChangedPersonsLimit

Syntax:

 array getChangedPersonsLimit( int $timestamp, int $count, int $offset ) 


Beschreibung:

Gibt ein Array von Personen zurück, die seit timestamp geändert wurden.

Hinweis: Es werden nur Kontakte zurückgegeben, für welche der authentifizierte Nutzer Leseberechtigungen hat.

$count ist die maximale Anzahl an Ergebnissen, die zurückgegeben werden soll. Wenn auf 0 gesetzt, wird ein Array ohne Größenlimit zurückgegeben..

$offset ist die Offset Position der Ergebnisse, die zurückgegeben werden sollen. Diese Variable hat keinen Effekt, wenn $count nicht gesetzt ist..


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get only 10 persons, which have been changed since the last 10 days.
    $persons = $crmapi_contacts->getChangedPersonsLimit(time()-3600*24*10, 10, 0);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($persons as $person) {
    foreach($person as $key => $val) {
        echo "$key => $val<br/>\n";
    }
}
?>

getPersonIds

Syntax:

 array getPersonIds( int $timestamp ) 


Beschreibung:

Gibt ein Array von person ids zurück, die seit timestamp geändert wurden.

Wirft eine CRMException im Fehlerfall.

Hinweis: Es werden nur Personen zurückgegeben, für welche der authentifizierte Nutzer Leseberechtigungen hat.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get person ids, which have been changed since the last 10 days.
    $person_ids = $crmapi_contacts->getPersonIds(time()-3600*24*10);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($person_ids as $person_id) {
    echo "$person_id<br/>\n";
}
?>

getContactPermission

Syntax:

 array getContactPermission( int $contact_id ) 


Beschreibung:

Gibt ein assoziatives $permissions array mit den Berechtigungen für den Kontakt mit der gegebenen $contact_id zurück.

Wirft eine CRMException im Fehlerfall.


Eigenschaften von $permissions array:

Type(Length)	Key           Value       
-------------------------------------------------------------------------------
array		users         Array mit $user_permission arrays
array		groups        Array mit $group_permission arrays

Eigenschaften von $user_permission array:

Type(Length)	   Eigenschaft             Beschreibung
-------------------------------------------------------------------------------
int                Key                  User's ID
array		   Value                read:   1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        write:  1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        delete: 1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert

Eigenschaften von $group_permission array:

Type(Length)	   Eigenschaft             Beschreibung
-------------------------------------------------------------------------------
int                Key                  Group's ID
array		   Value                read:   1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        write:  1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        delete: 1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $permissions = $crmapi_contacts->getContactPermission('123');
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach($permissions as $type => $permission) {
 
    echo "Type: $type<br/>\n";
 
    foreach($permission as $single_id => $single_permissions) {
 
        echo "User id/Group id: $single_id<br/>\n";
 
            foreach($single_permission as $permission_type => $permission_set) {
                echo "$permission_type => $permission_set<br/>\n";
            }
    }
}
?>

setContactPermission

Syntax:

 boolean setContactPermission( array $permission) 


Beschreibung:

Setzt die Berechtigungen für einen einzelnen Kontakt.

Gibt true bei Erfolg zurück.

Wirft eine CRMException im Fehlerfall.


Eigenschaften von $permissions array:

Type(Length)	Key           Value       
-------------------------------------------------------------------------------
array		users         Array mit $user_permission arrays
array		groups        Array mit $group_permission arrays

Eigenschaften von $user_permission array:

Type(Length)	   Eigenschaft             Beschreibung
-------------------------------------------------------------------------------
int                Key                  User's ID
array		   Value                read:   1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        write:  1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        delete: 1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert

Eigenschaften von $group_permission array:

Type(Length)	   Eigenschaft             Beschreibung
-------------------------------------------------------------------------------
int                Key                  Group's ID
array		   Value                read:   1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        write:  1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert
                                        delete: 1 = gesetzt, 0 = nicht gesetzt, -1 = verweigert

Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $permission = array('cid'    => 1234,
			'users'  => array( '55' => array('read' => -1, 
							 'write' => -1, 
							 'delete' => -1) ),
 
                        'groups' => array( '33' => array('read' => -1, 
							 'write' => -1, 
							 'delete' => -1) ),
		        );
 
    $success = $crmapi_contacts->setContactPermission($permission);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
echo $success;
?>

getContactByRealNumber

Wird ab die Version (CRM >= 3.3.4353) NICHT mehr ünterstützt

Syntax:

 array getContactByRealNumber( string|array $realnumbers ) 


Beschreibung:

Gibt ein contacts array mit den real numbers als Key zurück.

$real_number kann entweder ein Array mit real numbers oder ein String mit verketteten real numbers im Format "realnumber1:realnumber2:..." sein

Hinweis: $real_number ist die angzeigte Kontaktnummer, nicht die Kontakt-Id. Der Key für diese Eigenschaft im $contact_array und $single_contact_result ist 'number', der Key in einem $contact_result array ist 'contact_number'


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $contacts = $crmapi_contacts->getContactByRealNumber(12345);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $contacts as $contact) {
    foreach( $contact as $key => $val) {
        echo "$key => $val";
    }
}
?>

deleteContact

Syntax:

 void deleteContact( int $contact_id ) 


Beschreibung:

Löscht einen Kontakt

Wirft eine CRMException im Fehlerfall.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $crmapi_contacts->deleteContact(1234);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
?>

deletePerson

Syntax:

 void deletePerson( int $person_id ) 


Beschreibung:

Löscht eine Person

Wirft eine CRMException im Fehlerfall.


Beispiel:

<?php
try {
    $crmapi_contacts = crmapi::contacts();
 
    $crmapi_contacts->deletePerson(1234);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
?>

getContactUserFields

(CRM >= 3.3.4005)

Syntax:

 array getContactUserFields( int $contact_id ) 


Beschreibung:

Gibt ein Array mit allen benutzerdefinierten Feldern des Kontaktes mit der angegebenen contact_id zurück.

Im Falle eines Fehlers wird eine CRMException mit mehr Fehlerdetails geworfen.


Eignenschaften von ContactUserField array:

Typ(Länge)              Eigenschaft               Beschreibung
---------------------------------------------------------------------------------------------
string(255)             Key                       Name des benutzerdefinierten Kontaktfeldes
string(255)             Value                     Wert des benutzerdefinierten Kontaktfeldes


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $user_fields = $crmapi_contacts->getContactUserFields(423);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $user_fields as $key => $val) {
    echo "$key => $val<br/>\n";
}
 
?>

getPersonUserFields

(CRM >= 3.3.4005)

Syntax:

 array getPersonUserFields( int $person_id ) 


Beschreibung:

Gibt ein Array mit allen benutzerdefinierten Feldern der Person mit der angegebenen person_id zurück.

Im Falle eines Fehlers wird eine CRMException mit allen Fehlerdetails geworfen.


Eignenschaften von PersonUserField array:

Typ(Länge)              Eigenschaft               Beschreibung
---------------------------------------------------------------------------------------------
string(255)             Key                       Name des benutzerdefinierten Personenfeldes
string(255)             Value                     Wert des benutzerdefinierten Personenfeldes


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $user_fields = $crmapi_contacts->getPersonUserFields(4273);
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $user_fields as $key => $val) {
    echo "$key => $val<br/>\n";
}
 
?>

getPersonsByContactIDs

(CRM >= 3.3.4005)

Syntax:

 array getPersonsByContactIDs( array $cids ) 


Beschreibung:

Gibt ein Array mit allen Personen zurück, die zu den gegebenen Kontakt-IDs gehören.

Im Falle eines Fehlers wird eine CRMException mit allen Fehlerdetails geworfen.


Eignenschaften von zurückgegebenen array:

Typ(Länge)              Eigenschaft               Beschreibung
---------------------------------------------------------------------------------------------
string(255)             Key                       Kontakt ID
string(255)             Value                     Personen Array

Eignenschaften von Personen Array:

sind die selben wie für #getSinglePerson.


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $result = $crmapi_contacts->getPersonsByContactIDs(array(1234, 1235));
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $result as $cid => $persons ) {
    echo "Kontakt ID: ". $cid. "<br>";
 
    foreach( $persons as $key => $value ) {
        echo "$key => $value<br/>\n";
    }
}
 
?>

getPicture

(CRM >= 3.3.3650)

Syntax:

array getPicture ( int $cid )

Beschreibung:

Gib den Binärer Inhalt des Bildes von einem Kontakt zurück.

cid ist die Kontakt-ID.

Eigenschaften von zurückgegebenen Array:

Type(Length)      Eigenschaft                     Beschreibung
---------------------------------------------------------------------------------------
string            $picture_big                    String mit Binärer Inhalt des Bildes (base64 kodiert)
string            $picture_small                  String mit Binärer Inhalt des Bildes (base64 kodiert)

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $result = $crmapi_contacts->getPicture( 1235 );
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
$small_pic_data = base64_decode($result['picture_small']);
$big_pic_data   = base64_decode($result['picture_big']);
 
if( file_put_contents("../fotos/small_picture.jpg", $small_pic_data) )
    echo 'Small picture created successfully';
else
    echo 'Error by creating small picture';
 
if( file_put_contents("../fotos/big_picture.jpg", $big_pic_data) )
    echo 'Big picture created successfully';
else
    echo 'Error by creating big picture';
?>

setPicture

(CRM >= 3.3.3650)

Syntax:

boolean setPicture ( int $cid, string $picture_data )

Beschreibung:

Läd ein Bild zu einem Kontakt hoch.

cid ist die Kontakt-ID.

picture_data ist Binärer Inhalt des Bildes (base64-kodiert).

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $file    = "../fotos/bild.jpg";
    $foto_content = base64_encode(file_get_contents($file));
 
    $success = $crmapi_contacts->setPicture( 1235, $foto_content );
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
if($success)
    echo 'Picture uploaded successfully.';
 
?>

getPersonPicture

(CRM >= 3.4.5086)

Syntax:

array getPersonPicture ( int $pid )

Beschreibung:

Gib den Binärer Inhalt des Bildes von einem Person zurück.

pid ist die Person-ID.

Eigenschaften von zurückgegebenen Array:

Type(Length)      Eigenschaft                     Beschreibung
---------------------------------------------------------------------------------------
string            $picture_big                    String mit Binärer Inhalt des Bildes (base64 kodiert)
string            $picture_small                  String mit Binärer Inhalt des Bildes (base64 kodiert)

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $result = $crmapi_contacts->getPersonPicture( 1235 );
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
$small_pic_data = base64_decode($result['picture_small']);
$big_pic_data   = base64_decode($result['picture_big']);
 
if( file_put_contents("../fotos/small_picture.jpg", $small_pic_data) )
    echo 'Small picture created successfully';
else
    echo 'Error by creating small picture';
 
if( file_put_contents("../fotos/big_picture.jpg", $big_pic_data) )
    echo 'Big picture created successfully';
else
    echo 'Error by creating big picture';
?>

setPersonPicture

(CRM >= 3.4.5086)

Syntax:

boolean setPersonPicture ( int $pid, string $picture_data )

Beschreibung:

Läd ein Bild zu einem Person hoch.

pid ist die Person-ID.

picture_data ist Binärer Inhalt des Bildes (base64-kodiert).

Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $file    = "../fotos/bild.jpg";
    $foto_content = base64_encode(file_get_contents($file));
 
    $success = $crmapi_contacts->setPersonPicture( 1235, $foto_content );
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
if($success)
    echo 'Picture uploaded successfully.';
 
?>

getContactFields

(CRM >= 3.3.4005)

Syntax:

 array getContactFields() 


Beschreibung:

Gibt ein Array mit Information der Feldern für Kontakte zurück. Die Info enthält die Felder in der Datenbank, die angezeigte Namen und die Typen der Felder.

Im Falle eines Fehlers wird eine CRMException mit mehr Fehlerdetails geworfen.


Eignenschaften von zurückgegebenen array:

Typ(Länge)              Eigenschaft               Beschreibung
---------------------------------------------------------------------------------------------
string(255)             Key                       Name des Feldes in der Datenbank
array(255)              Value                     Array mit 
                                                  label: der angezeigte Name des Feldes
                                                  field: Name des Feldes in der Datenbank
                                                  type:  Typ des Feldes


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $fields = $crmapi_contacts->getContactFields();
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $fields as $key => $val) {
    echo $key " => ". $val['label'] ."<br/>";
}
 
?>

getPersonFields

(CRM >= 3.3.4005)

Syntax:

 array getPersonFields() 


Beschreibung:

Gibt ein Array mit Information der Feldern für Personen zurück. Die Info enthält die Felder in der Datenbank, die angezeigte Namen und die Typen der Felder.

Im Falle eines Fehlers wird eine CRMException mit mehr Fehlerdetails geworfen.


Eignenschaften von zurückgegebenen array:

Typ(Länge)              Eigenschaft               Beschreibung
---------------------------------------------------------------------------------------------
string(255)             Key                       Name des Feldes in der Datenbank
array(255)              Value                     Array mit 
                                                  label: der angezeigte Name des Feldes
                                                  field: Name des Feldes in der Datenbank
                                                  type:  Typ des Feldes


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    $fields = $crmapi_contacts->getPersonFields();
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $fields as $key => $val) {
    echo $key " => ". $val['label'] ."<br/>";
}
 
?>

getContactsArray

(CRM >= 3.4.5005)

Syntax:

 array getContactsArray(array $cidpids) 


Beschreibung:

Gibt ein Array mit Information von Kontakten und Personen zurück.

Element des $cidpids Arrays hat der Format 'cid:pid' oder 'cid'.

Im Falle eines Fehlers wird eine CRMException mit mehr Fehlerdetails geworfen.


Eignenschaften von zurückgegebenen array: die gleichen wie für #getContact


Beispiel:

<?php
 
try {
    $crmapi_contacts = crmapi::contacts();
 
    // Get contact with ID = 7, person with ID = 8 AND contact with ID = 9
    $results = $crmapi_contacts->getContactsArray(array('7:8', '9'));
}
catch (CRMException $e) {
    echo $e->getMessage();
}
 
foreach( $results as $val) {
    echo $val['contact_company'] ."<br/>";
 
    if (isset($val['person_firstname'])) 
        echo  ". $val['person_firstname'] ."<br/>";
}
 
?>