<aside> ⚠️ Note: This documentation is for the first version of our API which is now deprecated. You should probably be looking at the docs for our new API instead, which you can find here.

</aside>

The GetContact function is used to retrieve a contact's information.

When calling this function, the Function parameter sent to the API should be GetContact.

Parameters

ContactId - This is the Id of the contact. If you added the contact via the API, you'll already have the Id. If you're using a contact that you entered from the CRM, this page explains how to find the Id.

‍****Note:** ContactId should be treated like a string, NOT an integer or any other number type.**

Example Code

This code shows how to get an existing contact with their Contact Id.

<?php
/************************************************************************************
    This file demonstrates how to use the Less Annoying CRM API to get a contact or
    company's information
     
    If you have any questions, feel free to email [email protected] for help
**************************************************************************************/
 
//Get your user UserCode and API token from <https://www.lessannoyingcrm.com/app/Settings/Api>
$UserCode = "ABCDE";
$APIToken = "111111111111111111111111111111111111111111111111";
$EndpointURL = "<https://api.lessannoyingcrm.com>";
 
/*
Notes:
This function requires a ContactId parameter. Even if you're retrieving a company,
pass the id in as "ContactId." As you can read about in our help documentation,
contacts and companies are the same thing in our database, so they both fit under
the "Contact" label in API functions.
*/
 
//First let's create an example contact
$Function = "CreateContact";
$Parameters = array(
    "FullName"=>"Tyler King",
);
 
$Result = CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters);
 
//Get the new ContactId
$ContactId = $Result['ContactId'];
 
$Function = "GetContact";
//All we need to do is set the ContactId
$Parameters = array(
    "ContactId"=>$ContactId
);
 
//The CallAPI function is at the bottom of this file
$Result = CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters);
 
//here's the contact's info:
var_dump($Result['Contact']);
 
function CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters){
    $APIResult = file_get_contents("$EndpointURL?UserCode=$UserCode&APIToken=$APIToken&".
                "Function=$Function&Parameters=".urlencode(json_encode($Parameters)));
    $APIResult = json_decode($APIResult, true);
     
    if(@$APIResult['Success'] === true){
        echo "Success!";
    }
    else{
        echo "API call failed. Error:".@$APIResult['Error'];
        exit;
    }
    return $APIResult;
}