【发布时间】:2022-09-23 13:31:35
【问题描述】:
大家好吗? 我的网站是基于 PHP 的。 我是 twilio 的新手,并以此构建简单的项目。 所以我应该实现的是使用 twilio 向用户发送消息,然后在我的站点中再次接收来自用户的消息。
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once \'./vendor/autoload.php\';
use Twilio\\Rest\\Client;
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = \'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\';
$token = \'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\';
$twilio = new Client($sid, $token);
$message = $twilio->messages
->create(\"+12099216581\", // to
[
\"body\" => \"This is test\",
\"from\" => \"+15324394442\",
\"statusCallback\" => \"\"
]
);
print($message->sid);
这是为了向我现在使用的一个用户发送消息.. 然后...
<?php
require_once \'./vendor/autoload.php\';
use Twilio\\TwiML\\MessagingResponse;
$response = new MessagingResponse();
$response->message(\'This is message 1 of 2.\');
$response->message(\'This is message 2 of 2.\');
echo $response;
我认为这段代码会用文本向用户返回文本消息...... 如果我错了,请教我...
所以我现在正在尝试这样做,但我不知道如何在我的站点中接收消息的内容。 如果你有这方面的经验,请教我。 提前致谢。