function hubspot_get_recent in HubSpot 7.3
Same name and namespace in other branches
- 6.2 hubspot.module \hubspot_get_recent()
- 6 hubspot.module \hubspot_get_recent()
- 7 hubspot.module \hubspot_get_recent()
- 7.2 hubspot.module \hubspot_get_recent()
Gets the most recent HubSpot leads.
Parameters
int $n: The number of leads to fetch.
Return value
array
See also
http://docs.hubapi.com/wiki/Searching_Leads
1 call to hubspot_get_recent()
- hubspot_block_view in ./
hubspot.module - Implements hook_block_view().
File
- ./
hubspot.module, line 183 - Sends Webform results to HubSpot's Forms API.
Code
function hubspot_get_recent($n = 5) {
$access_token = variable_get('hubspot_access_token', '');
$n = intval($n);
if (empty($access_token)) {
return array(
'Error' => t('This site is not connected to a HubSpot Account.'),
);
}
$result = drupal_http_request("https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?access_token={$access_token}&count={$n}");
if ($result->code == 401) {
$refresh = hubspot_oauth_refresh();
if ($refresh) {
$access_token = variable_get('hubspot_access_token', '');
$result = drupal_http_request("https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?access_token={$access_token}&count={$n}");
}
}
return array(
'Data' => json_decode($result->data),
'Error' => isset($result->error) ? $result->error : '',
'HTTPCode' => $result->code,
);
}