Obter um formulário de inscrição

Neste trecho de código, você verá como recuperar os detalhes da Application especificada.

Exemplo

Você precisará garantir que os seguintes valores substituíveis sejam definidos no código de exemplo, utilizando qualquer método que lhe seja conveniente:

ChaveDescrição
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

VONAGE_APPLICATION_ID

The Vonage Application ID.

Escreva o código

Adicione o seguinte ao arquivo ` get-application.sh`:

curl -X "GET" "https://api.nexmo.com/v2/applications/$VONAGE_APPLICATION_ID" \
     -H 'Content-Type: application/json' \
     -u "$VONAGE_API_KEY:$VONAGE_API_SECRET"

Ver código-fonte completo

Execute seu código

Salve este arquivo no seu computador e execute-o:

./get-application.sh

Pré-requisitos

npm install @vonage/server-sdk

Crie um arquivo chamado ` get-application.js ` e insira o seguinte código:

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

const vonage = new Vonage({
  apiKey: VONAGE_API_KEY,
  apiSecret: VONAGE_API_SECRET,
});

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao arquivo ` get-application.js`:

vonage.applications.getApplication(VONAGE_APPLICATION_ID)
  .then((resp) => console.log(resp))
  .catch((error) => console.error(error));

Ver código-fonte completo

Execute seu código

Salve este arquivo no seu computador e execute-o:

node get-application.js

Pré-requisitos

Adicione o seguinte ao arquivo ` build.gradle`:

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

Crie um arquivo chamado ` GetApplication ` e adicione o código a seguir ao método ` main `:

val client = Vonage {
    apiKey(VONAGE_API_KEY)
    apiSecret(VONAGE_API_SECRET)
}

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao método ` main ` do arquivo ` GetApplication `:

client.application.application(VONAGE_APPLICATION_ID).get()

Ver código-fonte completo

Execute seu código

Podemos usar o plugin “ aplicativo ” para o Gradle a fim de simplificar a execução do nosso aplicativo. Atualize seu arquivo ` build.gradle ` com o seguinte:

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

Execute o seguinte comando ` gradle ` para rodar seu aplicativo, substituindo ` com.vonage.quickstart.kt.application ` pelo pacote que contém ` GetApplication`:

gradle run -Pmain=com.vonage.quickstart.kt.application.GetApplication

Pré-requisitos

Adicione o seguinte ao arquivo ` build.gradle`:

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

Crie um arquivo chamado ` GetApplication ` e adicione o código a seguir ao método ` main `:

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

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao método ` main ` do arquivo ` GetApplication `:

Application application = client.getApplicationClient().getApplication(VONAGE_APPLICATION_ID);

System.out.println(application.toJson());

Ver código-fonte completo

Execute seu código

Podemos usar o plugin “ aplicativo ” para o Gradle a fim de simplificar a execução do nosso aplicativo. Atualize seu arquivo ` build.gradle ` com o seguinte:

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

Execute o seguinte comando ` gradle ` para rodar seu aplicativo, substituindo ` com.vonage.quickstart.application ` pelo pacote que contém ` GetApplication`:

gradle run -Pmain=com.vonage.quickstart.application.GetApplication

Pré-requisitos

Install-Package Vonage

Crie um arquivo chamado ` GetApplication.cs ` e insira o seguinte código:

using Vonage;
using Vonage.Request;

Ver código-fonte completo

Adicione o seguinte ao arquivo ` GetApplication.cs`:

var credentials = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET);
var client = new VonageClient(credentials);

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao arquivo ` GetApplication.cs`:

var response = await client.ApplicationClient.GetApplicationAsync(VONAGE_APPLICATION_ID);

Ver código-fonte completo

Pré-requisitos

composer require vonage/client

Crie um arquivo chamado ` get-application.php ` e insira o seguinte código:

$basic  = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao arquivo ` get-application.php`:

try {
    $application = $client->applications()->get(VONAGE_APPLICATION_ID);

    echo $application->getId() . PHP_EOL;
    echo $application->getName() . PHP_EOL;
} catch (\Vonage\Client\Exception\Request $e) {
    echo "There was a problem with the request: " . $e->getMessage() . PHP_EOL;
} catch (\Vonage\Client\Exception\Server $e) {
    echo "The server encounted an error: " . $e->getMessage() . PHP_EOL;
}

Ver código-fonte completo

Execute seu código

Salve este arquivo no seu computador e execute-o:

php get-application.php

Pré-requisitos

pip install vonage python-dotenv

Escreva o código

Adicione o seguinte ao arquivo ` get-application.py`:

from vonage import Auth, Vonage
from vonage_application import ApplicationData

client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))

response: ApplicationData = client.application.get_application(VONAGE_APPLICATION_ID)

print(response)

Ver código-fonte completo

Execute seu código

Salve este arquivo no seu computador e execute-o:

python application/get-application.py

Pré-requisitos

gem install vonage

Crie um arquivo chamado ` get-application.rb ` e insira o seguinte código:

client = Vonage::Client.new(
  api_key: VONAGE_API_KEY,
  api_secret: VONAGE_API_SECRET
)

Ver código-fonte completo

Escreva o código

Adicione o seguinte ao arquivo ` get-application.rb`:

response = client.applications.get(VONAGE_APPLICATION_ID)

Ver código-fonte completo

Execute seu código

Salve este arquivo no seu computador e execute-o:

ruby get-application.rb