List Contacts from Highrise
October 5, 2009
Pull your contacts from highrise. Use this and the last post to do a one or two-way sync. More to come on this.
$highrise_url = 'http://yoururl.highrisehq.com'; // your highrise url, e.g. http://yourcompany.highrisehq.com
$api_token = ''; // your highrise api token; can be found under My Info
$task_assignee_user_id = ''; // user id of the highrise user who gets the task assigned
$curl = curl_init($highrise_url.'/people.xml');
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_USERPWD,$api_token.':x'); //Username (api token, fake password as per Highrise api)
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
$xml = curl_exec($curl);
curl_close($curl);
//Parse XML
$people = simplexml_load_string($xml);
//var_dump($people->person);
foreach ($people->person as $person )
{
//var_dump($person->{first-name});
echo "Name: ".$person->{'first-name'}.' '.$person->{'last-name'}."\n";
echo "Emails: \n";
foreach($person->{'contact-data'}->{'email-addresses'} as $email)
{
echo $email->{'email-address'}->address."\n";
}
echo "Phone Numbers: \n";
foreach($person->{'contact-data'}->{'phone-numbers'} as $phone)
{
echo $phone->{'phone-number'}->number."\n";
}
echo "=================\n";
}
return $id;