我想单独检索所有用户及其属性,因此我可以使用它们在一个整洁的列表中显示

I want to retrieve all the users and their properties individually, so i can use them for displaying in a neat list

当我运行它returns一个所有用户的列表。我不知道如何将它们分开。我已经检查过 https://developers.intercom.com/intercom-api-reference/reference#list-users 但它并没有真正帮助。

我还没有真正尝试过任何东西,因为我什至不知道从哪里开始。

$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);

它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":"xdxd@mynamejeff.nl","phone":"2112321","name":"Jeff","pseudonym":null,"avatar":{"type":"avatar","image_url":null},"app_id":"xco2b8a7","companies":{"type":"company.list","companies":[]},"location_data":

它 returns 对每个用户都是如此(想象一下这 x10)。

假设 $server_output 正在填充数据(正如您所说的那样),那么这也许应该有所帮助。

$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);
}

上面的示例输出:

ID:5d8b17e44b56e3bf87bf6128
Type:user
Name:Geronimo Bogtrotter
Email:geronimo@littlebighorn.com

ID:5d8b16b2558d909c887b7b16
Type:user
Name:Roland TB303
Email:roland@acid.com

每个用户可以使用的属性要多得多 - 我想这取决于您对填充哪些字段的要求 - 您或您公司的某个人可能添加了用户?!