简体   繁体   中英

Receive response messages to a particular number - Twilio

How can I get the SMS replies (reply messages to an SMS send from twilio) to a particular number? Now when I reply to a message I'm seeing the messages in my twilio account. I want to get those response SMS to one particular mobile number.

How can I do this? Thanks in advance.

Twilio developer evangelist here.

You can get all the messages sent to a Twilio number or to a number that has been messaging your Twilio number using the Messages list resource . You can filter on the number the message was sent to or sent from using URL parameters .

To get all the messages sent to a number in PHP, you can use the helper library and this code:

// Require composer's autoload to load dependencies. Not required if your environment handles this for you.
require __DIR__ . '/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "your_account_sid"; 
$token = "your_auth_token"; 
$client = new Client($sid, $token);

foreach ($client->account->messages(array('From' => 'NUMBER')) as $message) {
    echo $message->body;
}

Let me know if that helps at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM