When I run it returns a list of all users. I dont know how to seperate them. I already checked https://developers.intercom.com/intercom-api-reference/reference#list-users but it didn't really help.
I haven't really tried anything yet since i dont even know where to start.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.intercom.io/users");
$headers = [
'Authorization:Bearer key',
'Accept: application/json',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec($ch);
curl_close($ch);
It returns
"pages":{"type":"pages","next":null,"page":1,"per_page":50,"total_pages":1},"total_count":7,"limited":false,"type":"user.list","users":[{"type":"user","id":"5d8b1a7422b912ea9149d7b0","user_id":"42069","anonymous":false,"email":"[email protected]","phone":"2112321","name":"Jeff","pseudonym":null,"avatar":{"type":"avatar","image_url":null},"app_id":"xco2b8a7","companies":{"type":"company.list","companies":[]},"location_data":
It returns this for every user (so just imagine this x10).
Assuming that $server_output
is being populated with data ( as you have stated is the case ) then perhaps this ought to help.
$json=json_decode( $server_output );
$users=$json->users;
foreach( $users as $user ){
$type=$user->type;
$id=$user->id;
$email=$user->email;
$name=$user->name;
/* etc etc */
printf('
<pre>
ID:%s
Type:%s
Name:%s
Email:%s
</pre>',$id,$type,$name,$email);
}
Example output from the above:
ID:5d8b17e44b56e3bf87bf6128
Type:user
Name:Geronimo Bogtrotter
Email:[email protected]
ID:5d8b16b2558d909c887b7b16
Type:user
Name:Roland TB303
Email:[email protected]
There are considerably more properties available for each user - I guess it depends upon your requirements as to which fields have been populated - you, or someone in your company, presumably added users?!