Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

354
Visualizações
how to get response in json format using twilio sdk

I am using Twilio's PHP SDK to send SMS. Below is the code:

<?php
// Required if your environment does not handle autoloading
require './autoload.php';

// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;

// Your Account SID and Auth Token from twilio.com/console
$sid = 'XXXXXXXXXXXXXXXXXXXXXXXX';
$token = 'XXXXXXXXXXXXXXXXXXXX';
$client = new Client($sid, $token);

// Use the client to do fun stuff like send text messages!
$client->messages->create(
    // the number you'd like to send the message to
    '+XXXXXXXXXX',
    array(
        // A Twilio phone number you purchased at twilio.com/console
        'from' => '+XXXXXXXX',
        // the body of the text message you'd like to send
        'body' => 'Hey Jenny! Good luck on the bar exam!'
    )
);

**Response:
[Twilio.Api.V2010.MessageInstance accountSid=XXXXXXXXXXXXXXXX sid=XXXXXXXXXXXXXXX]**

How I can get the response in JSON Format? Any help is appreciated.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The quick answer is:

$json_string = json_encode(</POST|GET>);

Use the $_POST or $_GET super globals and you get a json string format.

e.g.

/*
 * Imagine this is the POST request
 *
 * $_POST = [
 *     'foo' => 'Hello',
 *     'bar' => 'World!'
 * ];
 *
 */


$json_string = json_encode($_POST); // You get → {"foo":"Hello","bar":"World!"}

In this way you encode the values in a JSON representation.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda