Pasar al contenido principal
You are viewing the Spanish (Mexico) site, but your language preference is set to English. Switch to English site →
Mensajería

API de mensajería programable

Integra una única API para enviar y recibir mensajes SMS, MMS y de WhatsApp de manera confiable.

Integra los mensajes globales a tu
app con unas pocas líneas de código

prog-message-api-chart.png

Envía notificaciones, alertas y mensajes de marketing en varios canales con una API que incluye un software para administrar los números de teléfono, envíos, cumplimiento y respuestas.

Capacidades

Decenas de características. Sin necesidad
de programación adicional.

  • Node.js
  • Node.js
  • C#
  • PHP
  • Ruby
  • C#
  • PHP
  • Python
  • Ruby
  • Java
  • Python
  • Java
  • Python
  • Java
  • curl
  • curl

                    <span class="code-line"><span class="c1">// Download the Node helper library from twilio.com/docs/node/install</span>
</span><span class="code-line"><span class="c1">// These vars are your accountSid and authToken from twilio.com/user/account</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messages</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span>
</span><span class="code-line">  <span class="p">{</span>
</span><span class="code-line">    <span class="nx">body</span><span class="o">:</span> <span class="s1">&#39;All in the game, yo&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">to</span><span class="o">:</span> <span class="s1">&#39;+14108675310&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">from</span><span class="o">:</span> <span class="s1">&#39;+15005550006&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="p">},</span>
</span><span class="code-line">  <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">sms</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
</span><span class="code-line">    <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">sms</span><span class="p">.</span><span class="nx">sid</span><span class="p">);</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">);</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the Node helper library from twilio.com/docs/node/install</span>
</span><span class="code-line"><span class="c1">// These consts are your accountSid and authToken from https://www.twilio.com/console</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messages</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">create</span><span class="p">({</span>
</span><span class="code-line">    <span class="nx">body</span><span class="o">:</span> <span class="s1">&#39;All in the game, yo&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">to</span><span class="o">:</span> <span class="s1">&#39;+14108675310&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">from</span><span class="o">:</span> <span class="s1">&#39;+15005550006&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="p">})</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">sms</span> <span class="p">=&gt;</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">sms</span><span class="p">.</span><span class="nx">sid</span><span class="p">));</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the twilio-csharp library from twilio.com/docs/csharp/install</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">class</span> <span class="nc">Example</span>
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line">    <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line">    <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Find your Account Sid and Auth Token at twilio.com/user/account</span>
</span><span class="code-line">        <span class="kt">string</span> <span class="n">AccountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="kt">string</span> <span class="n">AuthToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="kt">var</span> <span class="n">twilio</span> <span class="p">=</span> <span class="k">new</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">AccountSid</span><span class="p">,</span> <span class="n">AuthToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="kt">var</span> <span class="n">message</span> <span class="p">=</span> <span class="n">twilio</span><span class="p">.</span><span class="n">SendMessage</span><span class="p">(</span><span class="s">&quot;+15005550006&quot;</span><span class="p">,</span> <span class="s">&quot;+14108675310&quot;</span><span class="p">,</span> <span class="s">&quot;All in the game, yo&quot;</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="n">Sid</span><span class="p">);</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Get the PHP helper library from https://twilio.com/docs/libraries/php</span>
</span><span class="code-line"><span class="k">require_once</span> <span class="s1">&#39;/path/to/twilio-php/Services/Twilio.php&#39;</span><span class="p">;</span> <span class="c1">// Loads the library</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="nv">$accountSid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$authToken</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Services_Twilio</span><span class="p">(</span><span class="nv">$accountSid</span><span class="p">,</span> <span class="nv">$authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$message</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">account</span><span class="o">-&gt;</span><span class="na">messages</span><span class="o">-&gt;</span><span class="na">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="k">array</span><span class="p">(</span>
</span><span class="code-line">        <span class="s1">&#39;To&#39;</span>   <span class="o">=&gt;</span> <span class="s1">&#39;+15005550006&#39;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s1">&#39;From&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;+14108675310&#39;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s1">&#39;Body&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;All in the game, yo&#39;</span>
</span><span class="code-line">    <span class="p">)</span>
</span><span class="code-line"><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">echo</span> <span class="nv">$message</span><span class="o">-&gt;</span><span class="na">sid</span><span class="p">;</span>
</span>
                

                    <span class="code-line"><span class="c1"># Get twilio-ruby from twilio.com/docs/ruby/install</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Get your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line"><span class="vi">@client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">message</span> <span class="o">=</span> <span class="vi">@client</span><span class="o">.</span><span class="n">account</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">  <span class="ss">body</span><span class="p">:</span> <span class="s1">&#39;All in the game, yo&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">to</span><span class="p">:</span> <span class="s1">&#39;+14108675310&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">from</span><span class="p">:</span> <span class="s1">&#39;+15005550006&#39;</span>
</span><span class="code-line"><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">puts</span> <span class="n">message</span><span class="o">.</span><span class="n">sid</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the twilio-csharp library from twilio.com/docs/libraries/csharp</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Rest.Api.V2010.Account</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Types</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">class</span> <span class="nc">Example</span>
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line">    <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line">    <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Find your Account Sid and Auth Token at twilio.com/console</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">accountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">authToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="n">TwilioClient</span><span class="p">.</span><span class="n">Init</span><span class="p">(</span><span class="n">accountSid</span><span class="p">,</span> <span class="n">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="kt">var</span> <span class="n">to</span> <span class="p">=</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15005550006&quot;</span><span class="p">);</span>
</span><span class="code-line">        <span class="kt">var</span> <span class="n">message</span> <span class="p">=</span> <span class="n">MessageResource</span><span class="p">.</span><span class="n">Create</span><span class="p">(</span>
</span><span class="code-line">            <span class="n">to</span><span class="p">,</span>
</span><span class="code-line">            <span class="k">from</span><span class="p">:</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+14108675310&quot;</span><span class="p">),</span>
</span><span class="code-line">            <span class="n">body</span><span class="p">:</span> <span class="s">&quot;All in the game, yo&quot;</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="n">Sid</span><span class="p">);</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line"><span class="c1">// Get the PHP helper library from https://twilio.com/docs/libraries/php</span>
</span><span class="code-line"><span class="k">require_once</span> <span class="s1">&#39;/path/to/vendor/autoload.php&#39;</span><span class="p">;</span> <span class="c1">// Loads the library</span>
</span><span class="code-line"><span class="k">use</span> <span class="nx">Twilio\Rest\Client</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="nv">$sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Client</span><span class="p">(</span><span class="nv">$sid</span><span class="p">,</span> <span class="nv">$token</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$sms</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">messages</span><span class="o">-&gt;</span><span class="na">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="s2">&quot;+14108675310&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="k">array</span><span class="p">(</span>
</span><span class="code-line">        <span class="s2">&quot;from&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;+15005550006&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s2">&quot;body&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;All in the game, yo&quot;</span>
</span><span class="code-line">    <span class="p">)</span>
</span><span class="code-line"><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">echo</span> <span class="nv">$sms</span><span class="o">-&gt;</span><span class="na">sid</span><span class="p">;</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the Python helper library from twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">TwilioRestClient</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span>
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">message</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="n">body</span><span class="o">=</span><span class="s2">&quot;All in the game, yo&quot;</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+14108675310&quot;</span><span class="p">,</span> <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;+15005550006&quot;</span>
</span><span class="code-line"><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">sid</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1"># Get twilio-ruby from twilio.com/docs/ruby/install</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Get your Account SID and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line"><span class="vi">@client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">message</span> <span class="o">=</span> <span class="vi">@client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">  <span class="ss">body</span><span class="p">:</span> <span class="s1">&#39;All in the game, yo&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">to</span><span class="p">:</span> <span class="s1">&#39;+14108675310&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">from</span><span class="p">:</span> <span class="s1">&#39;+15005550006&#39;</span>
</span><span class="code-line"><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">puts</span> <span class="n">message</span><span class="o">.</span><span class="n">sid</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.TwilioRestClient</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.TwilioRestException</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.resource.factory.MessageFactory</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.resource.instance.Message</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">org.apache.http.NameValuePair</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">org.apache.http.message.BasicNameValuePair</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="c1">// Find your Account Sid and Token at twilio.com/user/account</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">TwilioRestException</span> <span class="p">{</span>
</span><span class="code-line">        <span class="n">TwilioRestClient</span> <span class="n">client</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="c1">// Build a filter for search</span>
</span><span class="code-line">        <span class="n">List</span><span class="o">&lt;</span><span class="n">NameValuePair</span><span class="o">&gt;</span> <span class="n">params</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;</span><span class="p">();</span>
</span><span class="code-line">        <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;Body&quot;</span><span class="p">,</span> <span class="s">&quot;All in the game, yo&quot;</span><span class="p">));</span>
</span><span class="code-line">        <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;To&quot;</span><span class="p">,</span> <span class="s">&quot;+14108675310&quot;</span><span class="p">));</span>
</span><span class="code-line">        <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;From&quot;</span><span class="p">,</span> <span class="s">&quot;+15005550006&quot;</span><span class="p">));</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">MessageFactory</span> <span class="n">messageFactory</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="na">getAccount</span><span class="p">().</span><span class="na">getMessageFactory</span><span class="p">();</span>
</span><span class="code-line">        <span class="n">Message</span> <span class="n">message</span> <span class="o">=</span> <span class="n">messageFactory</span><span class="p">.</span><span class="na">create</span><span class="p">(</span><span class="n">params</span><span class="p">);</span>
</span><span class="code-line">        <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the Python helper library from twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">message</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">        <span class="n">body</span><span class="o">=</span><span class="s2">&quot;All in the game, yo&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+5571981265131&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">sid</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.api.v2010.account.Message</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.type.PhoneNumber</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">  <span class="c1">// Find your Account Sid and Token at twilio.com/user/account</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">    <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">Message</span> <span class="n">sms</span> <span class="o">=</span> <span class="n">Message</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span><span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+14108675310&quot;</span><span class="p">),</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;15005550006&quot;</span><span class="p">),</span>
</span><span class="code-line">        <span class="s">&quot;All in the game, yo&quot;</span><span class="p">).</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">sms</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the Python helper library from twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">os</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="c1"># To set up environmental variables, see http://twil.io/secure</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_ACCOUNT_SID&#39;</span><span class="p">]</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_AUTH_TOKEN&#39;</span><span class="p">]</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">message</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="n">body</span><span class="o">=</span><span class="s2">&quot;All in the game, yo&quot;</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+5571981265131&quot;</span><span class="p">,</span> <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;&quot;</span>
</span><span class="code-line"><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">sid</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.api.v2010.account.Message</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.type.PhoneNumber</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">  <span class="c1">// Get your Account SID and Auth Token from https://twilio.com/console</span>
</span><span class="code-line">  <span class="c1">// To set up environment variables, see http://twil.io/secure</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_ACCOUNT_SID&quot;</span><span class="p">);</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_AUTH_TOKEN&quot;</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">    <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">Message</span> <span class="n">sms</span> <span class="o">=</span> <span class="n">Message</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span><span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+14108675310&quot;</span><span class="p">),</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;15005550006&quot;</span><span class="p">),</span>
</span><span class="code-line">        <span class="s">&quot;All in the game, yo&quot;</span><span class="p">).</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">sms</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line">curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;Body=All%20in%20the%20game%2C%20yo&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;To=%2B14108675310&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;From=%2B15005550006&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -u <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token&#39;</span>
</span>
                

                    <span class="code-line">curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;Body=All%20in%20the%20game%2C%20yo&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;To=%2B14108675310&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -d <span class="s2">&quot;From=%2B15005550006&quot;</span> <span class="se">\</span>
</span><span class="code-line">    -u <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token&#39;</span>
</span>
                

Mensajería de alto volumen con total cumplimiento

  • Remitentes globales de alto volumen: selecciona códigos cortos, ID de remitente alfanumérico y números gratuitos de alto rendimiento
  • Cancelación de suscripción avanzada: personaliza las opciones de adopción y exclusión de las regulaciones e idiomas locales en la consola
  • Redacción de mensajes: redacta los últimos 4 dígitos de los números de teléfono y el cuerpo del mensaje para proteger los datos confidenciales del cliente
  • Alertas de ID de remitente alfanumérico: recibe alertas automáticas cuando realices envíos a países que requieran ID de remitente alfanumérico previamente registrados
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • Python
  • Java
  • curl

                    <span class="code-line"><span class="c1">// Download the Node helper library from twilio.com/docs/libraries/node</span>
</span><span class="code-line"><span class="c1">// These consts are your accountSid and authToken from https://www.twilio.com/console</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">const</span> <span class="nx">opts</span> <span class="o">=</span> <span class="p">{</span>
</span><span class="code-line">  <span class="nx">friendlyName</span><span class="o">:</span> <span class="s1">&#39;My First Service&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="nx">statusCallback</span><span class="o">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span><span class="p">,</span>
</span><span class="code-line"><span class="p">};</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messaging</span><span class="p">.</span><span class="nx">services</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">opts</span><span class="p">)</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">response</span> <span class="p">=&gt;</span> <span class="p">{</span>
</span><span class="code-line">    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">response</span><span class="p">);</span>
</span><span class="code-line">  <span class="p">})</span>
</span><span class="code-line">  <span class="p">.</span><span class="k">catch</span><span class="p">(</span><span class="nx">error</span> <span class="p">=&gt;</span> <span class="p">{</span>
</span><span class="code-line">    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
</span><span class="code-line">  <span class="p">});</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the twilio-csharp library from twilio.com/docs/libraries/csharp</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Rest.Messaging.V1</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">
</span><span class="code-line"><span class="k">class</span> <span class="nc">Example</span>
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line">    <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span> <span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line">    <span class="p">{</span>
</span><span class="code-line">      <span class="c1">// Find your Account SID and Auth Token at twilio.com/console</span>
</span><span class="code-line">      <span class="k">const</span> <span class="kt">string</span> <span class="n">accountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">      <span class="k">const</span> <span class="kt">string</span> <span class="n">authToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">      <span class="k">const</span> <span class="kt">string</span> <span class="n">serviceFriendlyName</span> <span class="p">=</span> <span class="s">&quot;My First Service&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">      <span class="n">TwilioClient</span><span class="p">.</span><span class="n">Init</span><span class="p">(</span><span class="n">accountSid</span><span class="p">,</span> <span class="n">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">      <span class="kt">var</span> <span class="n">service</span> <span class="p">=</span> <span class="n">ServiceResource</span><span class="p">.</span><span class="n">Create</span><span class="p">(</span><span class="n">serviceFriendlyName</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">      <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">service</span><span class="p">.</span><span class="n">Sid</span><span class="p">);</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line"><span class="c1">// Get the PHP helper library from https://twilio.com/docs/libraries/php</span>
</span><span class="code-line"><span class="k">require_once</span> <span class="s1">&#39;/path/to/vendor/autoload.php&#39;</span><span class="p">;</span> <span class="c1">// Loads the library</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">use</span> <span class="nx">Twilio\Rest\Client</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$twilio</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Client</span><span class="p">(</span><span class="nv">$account_sid</span><span class="p">,</span> <span class="nv">$auth_token</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$service</span> <span class="o">=</span> <span class="nv">$twilio</span><span class="o">-&gt;</span><span class="na">messaging</span><span class="o">-&gt;</span><span class="na">v1</span><span class="o">-&gt;</span><span class="na">services</span><span class="o">-&gt;</span><span class="na">create</span><span class="p">(</span><span class="s2">&quot;My First Service&quot;</span><span class="p">,</span>
</span><span class="code-line">                                                    <span class="k">array</span><span class="p">(</span><span class="s1">&#39;statusCallback&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;http://requestb.in/1234abcd&quot;</span><span class="p">)</span>
</span><span class="code-line">                                                   <span class="p">);</span>
</span>
                

                    <span class="code-line"><span class="c1"># Get twilio-ruby from twilio.com/docs/libraries/ruby</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Get your Account SID and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Initialize Twilio Client</span>
</span><span class="code-line"><span class="vi">@client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="vi">@service</span> <span class="o">=</span> <span class="vi">@client</span><span class="o">.</span><span class="n">messaging</span><span class="o">.</span><span class="n">v1</span>
</span><span class="code-line">                  <span class="o">.</span><span class="n">services</span>
</span><span class="code-line">                  <span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">                    <span class="ss">friendly_name</span><span class="p">:</span> <span class="s1">&#39;My First Service&#39;</span><span class="p">,</span>
</span><span class="code-line">                    <span class="ss">status_callback</span><span class="p">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span>
</span><span class="code-line">                  <span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">puts</span> <span class="vi">@service</span><span class="o">.</span><span class="n">sid</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the Python helper library from twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span>
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">service</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messaging</span> \
</span><span class="code-line">                <span class="o">.</span><span class="n">services</span> \
</span><span class="code-line">                <span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">friendly_name</span><span class="o">=</span><span class="s2">&quot;My First Service&quot;</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">service</span><span class="o">.</span><span class="n">sid</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.messaging.v1.Service</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">    <span class="c1">// Find your Account Sid and Token at twilio.com/console</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Initialize the client</span>
</span><span class="code-line">        <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Service</span> <span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span><span class="s">&quot;My First Service&quot;</span><span class="p">).</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the Python helper library from twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">os</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="c1"># To set up environmental variables, see http://twil.io/secure</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_ACCOUNT_SID&#39;</span><span class="p">]</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_AUTH_TOKEN&#39;</span><span class="p">]</span>
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">service</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messaging</span> \
</span><span class="code-line">                <span class="o">.</span><span class="n">services</span> \
</span><span class="code-line">                <span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">friendly_name</span><span class="o">=</span><span class="s2">&quot;My First Service&quot;</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">service</span><span class="o">.</span><span class="n">sid</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.messaging.v1.Service</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">    <span class="c1">// Get your Account SID and Auth Token from https://twilio.com/console</span>
</span><span class="code-line">    <span class="c1">// To set up environment variables, see http://twil.io/secure</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_ACCOUNT_SID&quot;</span><span class="p">);</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_AUTH_TOKEN&quot;</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Initialize the client</span>
</span><span class="code-line">        <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Service</span> <span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span><span class="s">&quot;My First Service&quot;</span><span class="p">).</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line">curl <span class="s1">&#39;https://messaging.twilio.com/v1/Services&#39;</span> -X POST <span class="se">\</span>
</span><span class="code-line">    --data-urlencode <span class="s1">&#39;FriendlyName=My First Service&#39;</span> <span class="se">\</span>
</span><span class="code-line">    --data-urlencode <span class="s1">&#39;StatusCallback=http://requestb.in/1234abcd&#39;</span> <span class="se">\</span>
</span><span class="code-line">    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
</span>
                

Una experiencia local, incluso a medida que se escala a nivel mundial

  • A2P 10DLC: Envía mensajes a escala usando números locales mediante el registro para obtener un código largo de 10 dígitos A2P de EE. UU. verificado (10DLC)
  • Remitentes hiperlocales: elige entre más de 65 000 prefijos que incluyen números locales, nacionales y gratuitos
  • Sticky Sender: envía mensajes desde el mismo ID de remitente o número de teléfono para brindar una experiencia coherente
  • Código de área y Geomatch de país: selecciona automáticamente un número de teléfono según el código de área del consumidor (solo en EE. UU.) o el país
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • curl

                    <span class="code-line"><span class="c1">// Download the helper library from https://www.twilio.com/docs/node/install</span>
</span><span class="code-line"><span class="c1">// Your Account Sid and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="c1">// DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messages</span><span class="p">(</span><span class="s1">&#39;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span>
</span><span class="code-line">      <span class="p">.</span><span class="nx">media</span><span class="p">(</span><span class="s1">&#39;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span>
</span><span class="code-line">      <span class="p">.</span><span class="nx">fetch</span><span class="p">()</span>
</span><span class="code-line">      <span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">media</span> <span class="p">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">media</span><span class="p">.</span><span class="nx">contentType</span><span class="p">));</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the C# / .NET helper library from twilio.com/docs/csharp/install</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Rest.Api.V2010.Account.Message</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">
</span><span class="code-line"><span class="k">class</span> <span class="nc">Program</span> 
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line">    <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line">    <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Find your Account Sid and Token at twilio.com/console</span>
</span><span class="code-line">        <span class="c1">// DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">accountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">authToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">TwilioClient</span><span class="p">.</span><span class="n">Init</span><span class="p">(</span><span class="n">accountSid</span><span class="p">,</span> <span class="n">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="kt">var</span> <span class="n">media</span> <span class="p">=</span> <span class="n">MediaResource</span><span class="p">.</span><span class="n">Fetch</span><span class="p">(</span>
</span><span class="code-line">            <span class="n">pathMessageSid</span><span class="p">:</span> <span class="s">&quot;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">,</span>
</span><span class="code-line">            <span class="n">pathSid</span><span class="p">:</span> <span class="s">&quot;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line">        <span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">media</span><span class="p">.</span><span class="n">ContentType</span><span class="p">);</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Update the path below to your autoload.php,</span>
</span><span class="code-line"><span class="c1">// see https://getcomposer.org/doc/01-basic-usage.md</span>
</span><span class="code-line"><span class="k">require_once</span> <span class="s1">&#39;/path/to/vendor/autoload.php&#39;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">use</span> <span class="nx">Twilio\Rest\Client</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Find your Account Sid and Auth Token at twilio.com/console</span>
</span><span class="code-line"><span class="c1">// DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line"><span class="nv">$sid</span>    <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$token</span>  <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$twilio</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Client</span><span class="p">(</span><span class="nv">$sid</span><span class="p">,</span> <span class="nv">$token</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$media</span> <span class="o">=</span> <span class="nv">$twilio</span><span class="o">-&gt;</span><span class="na">messages</span><span class="p">(</span><span class="s2">&quot;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">)</span>
</span><span class="code-line">                <span class="o">-&gt;</span><span class="na">media</span><span class="p">(</span><span class="s2">&quot;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">)</span>
</span><span class="code-line">                <span class="o">-&gt;</span><span class="na">fetch</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">print</span><span class="p">(</span><span class="nv">$media</span><span class="o">-&gt;</span><span class="na">contentType</span><span class="p">);</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the helper library from https://www.twilio.com/docs/ruby/install</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;rubygems&#39;</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="c1"># DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line"><span class="vi">@client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">media</span> <span class="o">=</span> <span class="vi">@client</span><span class="o">.</span><span class="n">messages</span><span class="p">(</span><span class="s1">&#39;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span>
</span><span class="code-line">               <span class="o">.</span><span class="n">media</span><span class="p">(</span><span class="s1">&#39;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span>
</span><span class="code-line">               <span class="o">.</span><span class="n">fetch</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">puts</span> <span class="n">media</span><span class="o">.</span><span class="n">content_type</span>
</span>
                

                    <span class="code-line"><span class="c1"># Download the helper library from https://www.twilio.com/docs/python/install</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># Your Account Sid and Auth Token from twilio.com/console</span>
</span><span class="code-line"><span class="c1"># DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">media</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="p">(</span><span class="s1">&#39;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span> \
</span><span class="code-line">              <span class="o">.</span><span class="n">media</span><span class="p">(</span><span class="s1">&#39;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">)</span> \
</span><span class="code-line">              <span class="o">.</span><span class="n">fetch</span><span class="p">()</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nb">print</span><span class="p">(</span><span class="n">media</span><span class="o">.</span><span class="n">content_type</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.api.v2010.account.message.Media</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">    <span class="c1">// Find your Account Sid and Token at twilio.com/console</span>
</span><span class="code-line">    <span class="c1">// DANGER! This is insecure. See http://twil.io/secure</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">        <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">        <span class="n">Media</span> <span class="n">media</span> <span class="o">=</span> <span class="n">Media</span><span class="p">.</span><span class="na">fetcher</span><span class="p">(</span>
</span><span class="code-line">                <span class="s">&quot;MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">,</span>
</span><span class="code-line">                <span class="s">&quot;MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">)</span>
</span><span class="code-line">            <span class="p">.</span><span class="na">fetch</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">media</span><span class="p">.</span><span class="na">getContentType</span><span class="p">());</span>
</span><span class="code-line">    <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line">curl -X GET <span class="s1">&#39;https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media/MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json&#39;</span> <span class="se">\</span>
</span><span class="code-line">-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
</span>
                

El contenido del mensaje se entrega con precisión

  • API de contenido: traduce contenido de mensajes enriquecido en varios canales
  • Concatenación inteligente: divide en segmentos los mensajes largos de forma automática agregando un encabezado que los operadores móviles utilizan para volver a unirlos
  • Cifrado inteligente: envía mensajes SMS en el cifrado más compacto posible (utiliza UCS-2 para caracteres que no sean GSM-7)
  • Node.js
  • C#
  • PHP
  • Ruby
  • Python
  • Java
  • curl
  • twilio-cli
//Downloadthehelperlibraryfromhttps://www.twilio.com/docs/node/install//FindyourAccountSIDandAuthTokenattwilio.com/console//andsettheenvironmentvariables.Seehttp://twil.io/secureconstaccountSid=process.env.TWILIO_ACCOUNT_SID;constauthToken=process.env.TWILIO_AUTH_TOKEN;constclient=require('twilio')(accountSid,authToken);client.messages.create({from:'+15017122661',body:'body',to:'+15558675310'}).then(message=>console.log(message.sid));
// Install the C# / .NET helper library from twilio.com/docs/csharp/installusingSystem;usingTwilio;usingTwilio.Rest.Api.V2010.Account;classProgram{staticvoidMain(string[]args){// Find your Account SID and Auth Token at twilio.com/console// and set the environment variables. See http://twil.io/securestringaccountSid=Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");stringauthToken=Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");TwilioClient.Init(accountSid,authToken);varmessage=MessageResource.Create(from:newTwilio.Types.PhoneNumber("+15017122661"),body:"body",to:newTwilio.Types.PhoneNumber("+15558675310"));Console.WriteLine(message.Sid);}}
<?php// Update the path below to your autoload.php,// see https://getcomposer.org/doc/01-basic-usage.mdrequire_once'/path/to/vendor/autoload.php';useTwilio\Rest\Client;// Find your Account SID and Auth Token at twilio.com/console// and set the environment variables. See http://twil.io/secure$sid=getenv("TWILIO_ACCOUNT_SID");$token=getenv("TWILIO_AUTH_TOKEN");$twilio=newClient($sid,$token);$message=$twilio->messages->create("+15558675310",// to["from"=>"+15017122661","body"=>"body"]);print($message->sid);
# Download the helper library from https://www.twilio.com/docs/ruby/installrequire'rubygems'require'twilio-ruby'# Find your Account SID and Auth Token at twilio.com/console# and set the environment variables. See http://twil.io/secureaccount_sid=ENV['TWILIO_ACCOUNT_SID']auth_token=ENV['TWILIO_AUTH_TOKEN']@client=Twilio::REST::Client.new(account_sid,auth_token)message=@client.messages.create(from:'+15017122661',body:'body',to:'+15558675310')putsmessage.sid
# Download the helper library from https://www.twilio.com/docs/python/installimportosfromtwilio.restimportClient# Find your Account SID and Auth Token at twilio.com/console# and set the environment variables. See http://twil.io/secureaccount_sid=os.environ['TWILIO_ACCOUNT_SID']auth_token=os.environ['TWILIO_AUTH_TOKEN']client=Client(account_sid,auth_token)message=client.messages.create(from_='+15017122661',body='body',to='+15558675310')print(message.sid)
// Install the Java helper library from twilio.com/docs/java/installimportcom.twilio.Twilio;importcom.twilio.rest.api.v2010.account.Message;importcom.twilio.type.PhoneNumber;publicclassExample{// Find your Account SID and Auth Token at twilio.com/console// and set the environment variables. See http://twil.io/securepublicstaticfinalStringACCOUNT_SID=System.getenv("TWILIO_ACCOUNT_SID");publicstaticfinalStringAUTH_TOKEN=System.getenv("TWILIO_AUTH_TOKEN");publicstaticvoidmain(String[]args){Twilio.init(ACCOUNT_SID,AUTH_TOKEN);Messagemessage=Message.creator(newcom.twilio.type.PhoneNumber("+15558675310"),newcom.twilio.type.PhoneNumber("+15017122661"),"body").create();System.out.println(message.getSid());}}
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \--data-urlencode "From=+15017122661"\--data-urlencode "Body=body"\--data-urlencode "To=+15558675310"\-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
#Installthetwilio-clifromhttps://twil.io/clitwilioapi:core:messages:create\--from +15017122661 \--body body \--to +15558675310

Control programático sobre los mensajes entrantes y en cola

  • Periodo de validez de los SMS: determina durante cuánto tiempo se debe intentar entregar mensajes en cola antes de emitir un error
  • Webhooks entrantes: envía una solicitud de protocolo HTTP POST o GET a una URL especificada para los mensajes entrantes
  • API de Conversations: configura los mensajes entrantes para crear una conversación con la API de Conversations, a fin de obtener cadenas de mensajes clasificables
  • Node.js
  • Node.js
  • C#
  • PHP
  • Ruby
  • C#
  • PHP
  • Python
  • Ruby
  • Java
  • Python
  • Java
  • Python
  • Java
  • curl

                    <span class="code-line"><span class="c1">// Twilio Credentials</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// require the Twilio module and create a REST client</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messages</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span>
</span><span class="code-line">  <span class="p">{</span>
</span><span class="code-line">    <span class="nx">to</span><span class="o">:</span> <span class="s1">&#39;+15558675310&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">from</span><span class="o">:</span> <span class="s1">&#39;+15017122661&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">body</span><span class="o">:</span> <span class="s1">&#39;McAvoy or Stewart? These timelines can get so confusing.&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">statusCallback</span><span class="o">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="p">},</span>
</span><span class="code-line">  <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">message</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
</span><span class="code-line">    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">message</span><span class="p">.</span><span class="nx">sid</span><span class="p">);</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">);</span>
</span>
                

                    <span class="code-line"><span class="c1">// Twilio Credentials</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">accountSid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">authToken</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// require the Twilio module and create a REST client</span>
</span><span class="code-line"><span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;twilio&#39;</span><span class="p">)(</span><span class="nx">accountSid</span><span class="p">,</span> <span class="nx">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nx">client</span><span class="p">.</span><span class="nx">messages</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">create</span><span class="p">({</span>
</span><span class="code-line">    <span class="nx">to</span><span class="o">:</span> <span class="s1">&#39;+15558675310&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">from</span><span class="o">:</span> <span class="s1">&#39;+15017122661&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">body</span><span class="o">:</span> <span class="s1">&#39;McAvoy or Stewart? These timelines can get so confusing.&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="nx">statusCallback</span><span class="o">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="p">})</span>
</span><span class="code-line">  <span class="p">.</span><span class="nx">then</span><span class="p">(</span><span class="nx">message</span> <span class="p">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">message</span><span class="p">.</span><span class="nx">sid</span><span class="p">));</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the twilio-csharp library from twilio.com/docs/csharp/install</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="k">class</span> <span class="nc">Example</span>
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line"> <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line"> <span class="p">{</span>
</span><span class="code-line">    <span class="c1">// Find your Account Sid and Auth Token at twilio.com/user/account</span>
</span><span class="code-line">    <span class="kt">string</span> <span class="n">AccountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">    <span class="kt">string</span> <span class="n">AuthToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">    <span class="kt">var</span> <span class="n">twilio</span> <span class="p">=</span> <span class="k">new</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">AccountSid</span><span class="p">,</span> <span class="n">AuthToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="kt">var</span> <span class="n">message</span> <span class="p">=</span> <span class="n">twilio</span><span class="p">.</span><span class="n">SendMessage</span><span class="p">(</span>
</span><span class="code-line">        <span class="s">&quot;+15017122661&quot;</span><span class="p">,</span> <span class="s">&quot;+15558675310&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line">    <span class="p">);</span>
</span><span class="code-line">    <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="n">Sid</span><span class="p">);</span>
</span><span class="code-line"> <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// this line loads the library </span>
</span><span class="code-line"><span class="k">require</span><span class="p">(</span><span class="s1">&#39;/path/to/twilio-php/Services/Twilio.php&#39;</span><span class="p">);</span> 
</span><span class="code-line"> 
</span><span class="code-line"><span class="nv">$account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span><span class="p">;</span> 
</span><span class="code-line"><span class="nv">$auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span><span class="p">;</span> 
</span><span class="code-line"><span class="nv">$client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Services_Twilio</span><span class="p">(</span><span class="nv">$account_sid</span><span class="p">,</span> <span class="nv">$auth_token</span><span class="p">);</span> 
</span><span class="code-line"> 
</span><span class="code-line"><span class="nv">$client</span><span class="o">-&gt;</span><span class="na">account</span><span class="o">-&gt;</span><span class="na">messages</span><span class="o">-&gt;</span><span class="na">create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span> 
</span><span class="code-line">    <span class="s1">&#39;To&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;+15558675310&quot;</span><span class="p">,</span> 
</span><span class="code-line">    <span class="s1">&#39;From&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;+15017122661&quot;</span><span class="p">,</span> 
</span><span class="code-line">    <span class="s1">&#39;Body&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="s1">&#39;StatusCallback&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line"><span class="p">));</span>
</span>
                

                    <span class="code-line"><span class="nb">require</span> <span class="s1">&#39;rubygems&#39;</span> <span class="c1"># not necessary with ruby 1.9 but included for completeness</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># put your own credentials here</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># set up a client to talk to the Twilio REST API</span>
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span> <span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">body</span> <span class="o">=</span> <span class="s1">&#39;McAvoy or Stewart? These timelines can get so confusing.&#39;</span>
</span><span class="code-line"><span class="n">client</span><span class="o">.</span><span class="n">account</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="ss">from</span><span class="p">:</span> <span class="s1">&#39;+15017122661&#39;</span><span class="p">,</span>
</span><span class="code-line">                               <span class="ss">to</span><span class="p">:</span> <span class="s1">&#39;+15558675310&#39;</span><span class="p">,</span>
</span><span class="code-line">                               <span class="ss">body</span><span class="p">:</span> <span class="n">body</span><span class="p">,</span>
</span><span class="code-line">                               <span class="ss">status_callback</span><span class="p">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Download the twilio-csharp library from twilio.com/docs/libraries/csharp</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Rest.Api.V2010.Account</span><span class="p">;</span>
</span><span class="code-line"><span class="k">using</span> <span class="nn">Twilio.Types</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="k">class</span> <span class="nc">Example</span>
</span><span class="code-line"><span class="p">{</span>
</span><span class="code-line">   <span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span>
</span><span class="code-line">   <span class="p">{</span>
</span><span class="code-line">        <span class="c1">// Find your Account Sid and Auth Token at twilio.com/console</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">accountSid</span> <span class="p">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="k">const</span> <span class="kt">string</span> <span class="n">authToken</span> <span class="p">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">        <span class="n">TwilioClient</span><span class="p">.</span><span class="n">Init</span><span class="p">(</span><span class="n">accountSid</span><span class="p">,</span> <span class="n">authToken</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="kt">var</span> <span class="n">to</span> <span class="p">=</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15017122661&quot;</span><span class="p">);</span>
</span><span class="code-line">        <span class="kt">var</span> <span class="n">message</span> <span class="p">=</span> <span class="n">MessageResource</span><span class="p">.</span><span class="n">Create</span><span class="p">(</span>
</span><span class="code-line">            <span class="n">to</span><span class="p">,</span>
</span><span class="code-line">            <span class="k">from</span><span class="p">:</span> <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15558675310&quot;</span><span class="p">),</span>
</span><span class="code-line">            <span class="n">body</span><span class="p">:</span> <span class="s">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">            <span class="n">statusCallback</span><span class="p">:</span> <span class="k">new</span> <span class="n">Uri</span><span class="p">(</span><span class="s">&quot;http://requestb.in/1234abcd&quot;</span><span class="p">));</span>
</span><span class="code-line">
</span><span class="code-line">        <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="n">Sid</span><span class="p">);</span>
</span><span class="code-line">   <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="cp">&lt;?php</span>
</span><span class="code-line"><span class="c1">// Get the PHP helper library from https://twilio.com/docs/libraries/php</span>
</span><span class="code-line"><span class="k">require_once</span> <span class="s1">&#39;/path/to/vendor/autoload.php&#39;</span><span class="p">;</span> <span class="c1">// Loads the library</span>
</span><span class="code-line"><span class="k">use</span> <span class="nx">Twilio\Rest\Client</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1">// Your Account Sid and Auth Token from twilio.com/user/account</span>
</span><span class="code-line"><span class="nv">$sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line"><span class="nv">$client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Client</span><span class="p">(</span><span class="nv">$sid</span><span class="p">,</span> <span class="nv">$token</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line"><span class="nv">$client</span><span class="o">-&gt;</span><span class="na">messages</span><span class="o">-&gt;</span><span class="na">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="s1">&#39;+15558675310&#39;</span><span class="p">,</span>
</span><span class="code-line">    <span class="k">array</span><span class="p">(</span>
</span><span class="code-line">        <span class="s1">&#39;from&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;+15017122661&#39;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s1">&#39;body&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">        <span class="s1">&#39;statusCallback&#39;</span> <span class="o">=&gt;</span> <span class="s2">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line">    <span class="p">)</span>
</span><span class="code-line"><span class="p">);</span>
</span>
                

                    <span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">TwilioRestClient</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># put your own credentials here</span>
</span><span class="code-line"><span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line"><span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+15558675310&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;+15017122661&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">body</span><span class="o">=</span><span class="s2">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">status_callback</span><span class="o">=</span><span class="s2">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line"><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="nb">require</span> <span class="s1">&#39;rubygems&#39;</span> <span class="c1"># not necessary with ruby 1.9 but included for completeness</span>
</span><span class="code-line"><span class="nb">require</span> <span class="s1">&#39;twilio-ruby&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># put your own credentials here</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s1">&#39;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s1">&#39;your_auth_token&#39;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># set up a client to talk to the Twilio REST API</span>
</span><span class="code-line"><span class="vi">@client</span> <span class="o">=</span> <span class="no">Twilio</span><span class="o">::</span><span class="no">REST</span><span class="o">::</span><span class="no">Client</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="vi">@client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">  <span class="ss">from</span><span class="p">:</span> <span class="s1">&#39;+15017122661&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">to</span><span class="p">:</span> <span class="s1">&#39;+15558675310&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">body</span><span class="p">:</span> <span class="s1">&#39;McAvoy or Stewart? These timelines can get so confusing.&#39;</span><span class="p">,</span>
</span><span class="code-line">  <span class="ss">status_callback</span><span class="p">:</span> <span class="s1">&#39;http://requestb.in/1234abcd&#39;</span>
</span><span class="code-line"><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// You may want to be more specific in your imports</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">java.util.*</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.*</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.resource.factory.*</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.resource.instance.*</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.sdk.resource.list.*</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">org.apache.http.NameValuePair</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">org.apache.http.message.BasicNameValuePair</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TwilioTest</span> <span class="p">{</span>
</span><span class="code-line"> <span class="c1">// Find your Account Sid and Token at twilio.com/user/account</span>
</span><span class="code-line"> <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line"> <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span><span class="n">args</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">TwilioRestException</span> <span class="p">{</span>
</span><span class="code-line">  <span class="n">TwilioRestClient</span> <span class="n">client</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TwilioRestClient</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">   <span class="c1">// Build the parameters</span>
</span><span class="code-line">   <span class="n">List</span><span class="o">&lt;</span><span class="n">NameValuePair</span><span class="o">&gt;</span> <span class="n">params</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">NameValuePair</span><span class="o">&gt;</span><span class="p">();</span>
</span><span class="code-line">   <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;To&quot;</span><span class="p">,</span> <span class="s">&quot;+15558675310&quot;</span><span class="p">));</span>
</span><span class="code-line">   <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;From&quot;</span><span class="p">,</span> <span class="s">&quot;+15017122661&quot;</span><span class="p">));</span>
</span><span class="code-line">   <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;Body&quot;</span><span class="p">,</span> <span class="s">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">));</span>
</span><span class="code-line">   <span class="n">params</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">BasicNameValuePair</span><span class="p">(</span><span class="s">&quot;StatusCallback&quot;</span><span class="p">,</span> <span class="s">&quot;http://requestb.in/1234abcd&quot;</span><span class="p">));</span>
</span><span class="code-line">
</span><span class="code-line">   <span class="n">MessageFactory</span> <span class="n">messageFactory</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="na">getAccount</span><span class="p">().</span><span class="na">getMessageFactory</span><span class="p">();</span>
</span><span class="code-line">   <span class="n">Message</span> <span class="n">message</span> <span class="o">=</span> <span class="n">messageFactory</span><span class="p">.</span><span class="na">create</span><span class="p">(</span><span class="n">params</span><span class="p">);</span>
</span><span class="code-line">   <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line"> <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># put your own credentials here</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="s2">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="s2">&quot;your_auth_token&quot;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+15558675310&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;+15017122661&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">body</span><span class="o">=</span><span class="s2">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">status_callback</span><span class="o">=</span><span class="s2">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line"><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.api.v2010.account.Message</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.type.PhoneNumber</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">  <span class="c1">// Find your Account Sid and Token at twilio.com/user/account</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="s">&quot;ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;</span><span class="p">;</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="s">&quot;your_auth_token&quot;</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">    <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">Message</span> <span class="n">message</span> <span class="o">=</span> <span class="n">Message</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span>
</span><span class="code-line">      <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15558675310&quot;</span><span class="p">),</span>
</span><span class="code-line">      <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15017122661&quot;</span><span class="p">),</span>
</span><span class="code-line">      <span class="s">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">)</span>
</span><span class="code-line">        <span class="p">.</span><span class="na">setStatusCallback</span><span class="p">(</span><span class="s">&quot;http://requestb.in/1234abcd&quot;</span><span class="p">)</span>
</span><span class="code-line">        <span class="p">.</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line"><span class="kn">import</span> <span class="nn">os</span>
</span><span class="code-line"><span class="kn">from</span> <span class="nn">twilio.rest</span> <span class="kn">import</span> <span class="n">Client</span>
</span><span class="code-line">
</span><span class="code-line"><span class="c1"># put your own credentials here</span>
</span><span class="code-line"><span class="c1"># To set up environmental variables, see http://twil.io/secure</span>
</span><span class="code-line"><span class="n">account_sid</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_ACCOUNT_SID&#39;</span><span class="p">]</span>
</span><span class="code-line"><span class="n">auth_token</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;TWILIO_AUTH_TOKEN&#39;</span><span class="p">]</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">account_sid</span><span class="p">,</span> <span class="n">auth_token</span><span class="p">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="n">client</span><span class="o">.</span><span class="n">messages</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
</span><span class="code-line">    <span class="n">to</span><span class="o">=</span><span class="s2">&quot;+15558675310&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">from_</span><span class="o">=</span><span class="s2">&quot;+15017122661&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">body</span><span class="o">=</span><span class="s2">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">,</span>
</span><span class="code-line">    <span class="n">status_callback</span><span class="o">=</span><span class="s2">&quot;http://requestb.in/1234abcd&quot;</span>
</span><span class="code-line"><span class="p">)</span>
</span>
                

                    <span class="code-line"><span class="c1">// Install the Java helper library from twilio.com/docs/java/install</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.Twilio</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.rest.api.v2010.account.Message</span><span class="p">;</span>
</span><span class="code-line"><span class="kn">import</span> <span class="nn">com.twilio.type.PhoneNumber</span><span class="p">;</span>
</span><span class="code-line">
</span><span class="code-line"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Example</span> <span class="p">{</span>
</span><span class="code-line">  <span class="c1">// Get your Account SID and Auth Token from https://twilio.com/console</span>
</span><span class="code-line">  <span class="c1">// To set up environment variables, see http://twil.io/secure</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">ACCOUNT_SID</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_ACCOUNT_SID&quot;</span><span class="p">);</span>
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">AUTH_TOKEN</span> <span class="o">=</span> <span class="n">System</span><span class="p">.</span><span class="na">getenv</span><span class="p">(</span><span class="s">&quot;TWILIO_AUTH_TOKEN&quot;</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">  <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class="code-line">    <span class="n">Twilio</span><span class="p">.</span><span class="na">init</span><span class="p">(</span><span class="n">ACCOUNT_SID</span><span class="p">,</span> <span class="n">AUTH_TOKEN</span><span class="p">);</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">Message</span> <span class="n">message</span> <span class="o">=</span> <span class="n">Message</span><span class="p">.</span><span class="na">creator</span><span class="p">(</span>
</span><span class="code-line">      <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15558675310&quot;</span><span class="p">),</span>
</span><span class="code-line">      <span class="k">new</span> <span class="n">PhoneNumber</span><span class="p">(</span><span class="s">&quot;+15017122661&quot;</span><span class="p">),</span>
</span><span class="code-line">      <span class="s">&quot;McAvoy or Stewart? These timelines can get so confusing.&quot;</span><span class="p">)</span>
</span><span class="code-line">        <span class="p">.</span><span class="na">setStatusCallback</span><span class="p">(</span><span class="s">&quot;http://requestb.in/1234abcd&quot;</span><span class="p">)</span>
</span><span class="code-line">        <span class="p">.</span><span class="na">create</span><span class="p">();</span>
</span><span class="code-line">
</span><span class="code-line">    <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="na">getSid</span><span class="p">());</span>
</span><span class="code-line">  <span class="p">}</span>
</span><span class="code-line"><span class="p">}</span>
</span>
                

                    <span class="code-line">curl -X POST <span class="s1">&#39;https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json&#39;</span> <span class="se">\</span>
</span><span class="code-line">--data-urlencode <span class="s1">&#39;To=+15558675310&#39;</span>  <span class="se">\</span>
</span><span class="code-line">--data-urlencode <span class="s1">&#39;From=+15017122661&#39;</span>  <span class="se">\</span>
</span><span class="code-line">--data-urlencode <span class="s1">&#39;Body=McAvoy or Stewart? These timelines can get so confusing.&#39;</span>  <span class="se">\</span>
</span><span class="code-line">--data-urlencode <span class="s1">&#39;StatusCallback=http://requestb.in/1234abcd&#39;</span>  <span class="se">\</span>
</span><span class="code-line">-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
</span>
                

Total transparencia en la entrega de los mensajes y en la interacción

Ejemplos de código

Utiliza los ejemplos de código para crear
casos de uso comunes

Comenzar

Comienza a enviar mensajes en el
idioma que conoces

Recursos

Inicio rápido para enviar SMS

Aprende rápidamente a enviar mensajes usando tu idioma de preferencia.

Comienza con los mensajes de SMS

API de WhatsApp Business para el inicio rápido de Twilio

Agrega fácilmente las capacidades de WhatsApp con la misma mecánica de la API de Twilio que conoces.

Comienza con WhatsApp

Realiza un seguimiento del estado de entrega de los mensajes

Aprende a realizar un seguimiento del estado de entrega de los mensajes que envías con la mensajería programable en tu aplicación web.

Ve el tutorial

Recibir y responder mensajes

Aprende a utilizar la mensajería programable para responder a los mensajes de SMS entrantes en tu aplicación web.

Ve el tutorial

Referencia de la API

API de mensajería programable

Agrega sólidas capacidades de mensajería a tus aplicaciones con nuestra API de mensajería programable.

Consulta los documentos

API de WhatsApp Business

Utiliza una API REST para enviar notificaciones con la app de mensajería más popular del mundo, WhatsApp.

Consulta los documentos

Precios

Opciones de precios flexibles

Elige una estructura de precios sencilla adecuada para ti: Pago por consumo, descuentos por volumen o descuentos por uso comprometido según tu volumen mensual.

¿Por qué elegir Twilio?

Crea sobre la plataforma de Twilio. Programa con confianza.

Las mejores API de comunicación para mantener el ritmo de la conversación en todos los canales

Alcance global y una escala inigualable que admite a más de

8 millones de desarrolladores

Potentes herramientas sin servidor y soluciones totalmente programables que se implementan en minutos

Seguridad y confiabilidad de estándar empresarial que ayuda a más de 190 000 marcas respetadas