I’m trying to get values from a custom field(
birth date) from my pipedrive.
1- I made GET/person/ request to see whitch is the index that I needed that refers my custom field (birth date).
2 - After the step 1, I saw that my index was b6c3554a1267b01b16398ed31c61ea9ae13cf6d9 from the custom field and made the following PHP code:
<?php
// Pipedrive API token
$api_token = token;
// Pipedrive company domain
$company_domain = company;
//URL for Deal listing with your $company_domain and $api_token variables
$url = 'https://'.$company_domain.'.pipedrive.com/api/v1/persons?api_token=' . $api_token;
session_start();
try{
//b6c3554a1267b01b16398ed31c61ea9ae13cf6d9 <--- birth date
$pag = 0;
$limit = 100;
$more_items= true;
while($more_items ==true){
$data = http_build_query(array('start'=>($pag*$limit),'limit'=>$limit,'filter_id'=>69));
//GET request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url."&".$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to a PHP array
$result = json_decode($output, true);
if($result["success"]==true){
$persons = $result["data"];
foreach($persons as $person){
var_dump($person["name"]);
var_dump($person["b6c3554a1267b01b16398ed31c61ea9ae13cf6d9"]);
}
if($result["additional_data"]["pagination"]["more_items_in_collection"]==true){
$more_items = true;
$pag++;
}
else{
$more_items = false;
}
}
}
}
catch( Exception $e ) {
echo json_encode($e->getMessage());
}
?>
3 - I expected to receive all the names and birth dates, but I’m receiving some birth days and a lot of NULL’s instead.
4- prints: