メニュー

Expand
ページを評価:

Programmable Wireless: Send machine-to-machine SMS Commands

You’ve got a Programmable Wireless SIM in your device and you want to send a machine-to-machine command.

How are Commands different from Programmable SMS?

Programmable SMS is used to exchange text messages between people, while Commands use SMS as the means to deliver machine-to-machine messages.

You use Command resources to send a command message only to a Programmable Wireless SIM, not to a person’s phone number. Commands also provide some features such as binary message encoding, that are only useful for machine-to-machine workflows,.

You can read details about the Command resource in the Programmable Wireless API documentation.

Send a Command from your device

You want to send a Command from your device to Twilio’s servers to either:

How you send a Command is largely dependent on the type of device you use to send a text message. Generally, you need to do the following:

  1. Insert a Programmable Wireless SIM in the device.
  2. Make sure the SIM is registered to your account and in the Ready or Active status.
  3. Send an SMS to the short code 2936.

What is this 2936 number?

The 2936 number is a special reserved short code used to exchange Commands with your Twilio SIMs.

How does Programmable Wireless know what device sent that Command? Each SIM has a unique identifier associated with it. Programmable Wireless uses that unique identifier to send Commands through your account.

Verify that the machine received the Command

  • Navigate to the SIMs section of the Console.
  • At the list of SIMs on your account, click on the SIM that is in your device .
  • Click on the Commands tab at the top of the SIM details.
  • You should see your first Command sent from a machine to a machine.

Send a Command to your device

You can send Commands from any Internet-connected device using the Programmable Wireless API. You can do it right now on your computer. You’ll need to use the command line tool curl, which you may need to install. If you are running Linux or macOS, curl is probably installed already: run which curl to check. For Windows, you will need to install curl — you can find the software and instructions from the source here.

You will also need the following Twilio-specific credentials:

  • Your Programmable Wireless SIM’s SID or unique name. You can get this from the SIMs section of the Console.
  • Your Account SID and Auth Token, both of which are available from your console dashboard.

Copy the following code and paste it into a command line, then edit it to add your own credentials where marked. Make sure you remove the angle brackets. Windows users may need to remove the \ symbols and run the command on a single line:

curl -X POST https://wireless.twilio.com/v1/Commands \
--data-urlencode "Sim=<YOUR_SIM_SID_OR_NAME>" \
--data-urlencode "Command=hello_sim" \
-u <YOUR_ACCOUNT_SID>:<YOUR_AUTH_TOKEN>

This code creates a Command resource in the Twilio cloud which then triggers the transmission of the text in the Command field to the specified SIM.

On your computer, you will see see the JSON results of the POST you sent to Twilio via curl. Shortly, you’ll receive the Command itself on your device from the 2936 number.

Again, you can verify that that command was received by following the procedure described above, or you can check on the device itself if it has a suitable interface:

Command received!

ページを評価:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

        
        
        

        フィードバックくださりありがとうございます!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more