ユーザー一覧

このコードスニペットでは、Applications に関連する Users のリストを取得する方法を説明します。

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

コードを書く

list-users.sh に以下を追加する:

curl "https://api.nexmo.com/v1/users" \
     -H 'Authorization: Bearer '$JWT\
     -H 'Content-Type: application/json'

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

bash list-users.sh

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
npm install @vonage/server-sdk

list-users.js という名前のファイルを作成し、以下のコードを追加する:

const { Vonage } = require('@vonage/server-sdk');

const vonage = new Vonage({
  applicationId: VONAGE_APPLICATION_ID,
  privateKey: VONAGE_PRIVATE_KEY,
});

全文を見る

コードを書く

list-users.js に以下を追加する:

const run = async () => {
  try{
    for await (const user of vonage.users.listAllUsers()) {
      console.log(user);
    }
  } catch (error) {
    console.error(error);
  }
};

run();

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

node list-users.js

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

build.gradle に以下を追加する:

implementation 'com.vonage:server-sdk-kotlin:2.1.1'

ListUsers という名前のファイルを作成し、main メソッドに以下のコードを追加する:

val client = Vonage {
    applicationId(VONAGE_APPLICATION_ID)
    privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
}

全文を見る

コードを書く

ListUsers ファイルのmain メソッドに以下を追加する:

val users = client.users.list()

全文を見る

コードを実行する

Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

以下のgradle コマンドを実行し、com.vonage.quickstart.kt.usersListUsers を含むパッケージに置き換えてアプリケーションを実行する:

gradle run -Pmain=com.vonage.quickstart.kt.users.ListUsers

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

build.gradle に以下を追加する:

implementation 'com.vonage:server-sdk:9.3.1'

ListUsers という名前のファイルを作成し、main メソッドに以下のコードを追加する:

VonageClient client = VonageClient.builder()
        .apiKey(VONAGE_API_KEY)
        .apiSecret(VONAGE_API_SECRET)
        .build();

全文を見る

コードを書く

ListUsers ファイルのmain メソッドに以下を追加する:

List<BaseUser> users = client.getUsersClient().listUsers();

全文を見る

コードを実行する

Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

以下のgradle コマンドを実行し、com.vonage.quickstart.usersListUsers を含むパッケージに置き換えてアプリケーションを実行する:

gradle run -Pmain=com.vonage.quickstart.users.ListUsers

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Install-Package Vonage

GetUsers.cs という名前のファイルを作成し、以下のコードを追加する:

using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Vonage;
using Vonage.Request;
using Vonage.Users.GetUsers;

全文を見る

GetUsers.cs に以下を追加する:

var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var client = new VonageClient(credentials);

全文を見る

コードを書く

GetUsers.cs に以下を追加する:

var response = await client.UsersClient.GetUsersAsync(GetUsersRequest.Build().Create());

全文を見る

前提条件

You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
pip install vonage python-dotenv

コードを書く

list-users.py に以下を追加する:

from vonage import Auth, Vonage

client = Vonage(
    Auth(
        application_id=VONAGE_APPLICATION_ID,
        private_key=VONAGE_PRIVATE_KEY,
    )
)

users_list, next_page_cursor = client.users.list_users()

print(users_list)

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

python users/list-users.py

試してみる

コードを実行すると、アプリケーションに関連付けられたユーザのリストが表示されます。