python 的 twilio 短信
twilio sms with python
我希望将其转换为 php,任何人都可以。我正在编写营销应用程序代码以发送群发短信
from flask import Flask, request
from twilio.rest import TwilioRestClient
app = Flask(__name__)
# put your own credentials here
ACCOUNT_SID = 'YOUR_ACCOUNT_SID'
AUTH_TOKEN = 'YOUR_AUTH_TOKEN'
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
@app.route('/sms', methods=['POST'])
def send_sms():
message = client.messages.create(
to=request.form['To'],
from_='YOUR_TWILIO_PHONE_NUMBER',
body=request.form['Body'],
)
return message.sid
if __name__ == '__main__':
app.run()
此处为 Twilio 开发人员布道师。
how to send an SMS using Twilio and PHP right here 上有整页文档。
简而言之,要复制 Python,您应该 download or install the PHP helper library 到您的项目中。那么这段代码应该可以工作:
<?php
require_once "vendor/autoload.php";
use Twilio\Rest\Client;
$AccountSid = "YOUR_ACCOUNTS_SID";
$AuthToken = "YOUR_AUTH_TOKEN";
$client = new Client($AccountSid, $AuthToken);
$sms = $client->messages->create(
$_REQUEST['To'],
array(
'from' => "YOUR_TWILIO_NUMBER",
'body' => $_REQUEST['Body']
)
);
echo "Sent message";
我向 follow the documentation 推荐完整的说明。
我希望将其转换为 php,任何人都可以。我正在编写营销应用程序代码以发送群发短信
from flask import Flask, request
from twilio.rest import TwilioRestClient
app = Flask(__name__)
# put your own credentials here
ACCOUNT_SID = 'YOUR_ACCOUNT_SID'
AUTH_TOKEN = 'YOUR_AUTH_TOKEN'
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
@app.route('/sms', methods=['POST'])
def send_sms():
message = client.messages.create(
to=request.form['To'],
from_='YOUR_TWILIO_PHONE_NUMBER',
body=request.form['Body'],
)
return message.sid
if __name__ == '__main__':
app.run()
此处为 Twilio 开发人员布道师。
how to send an SMS using Twilio and PHP right here 上有整页文档。
简而言之,要复制 Python,您应该 download or install the PHP helper library 到您的项目中。那么这段代码应该可以工作:
<?php
require_once "vendor/autoload.php";
use Twilio\Rest\Client;
$AccountSid = "YOUR_ACCOUNTS_SID";
$AuthToken = "YOUR_AUTH_TOKEN";
$client = new Client($AccountSid, $AuthToken);
$sms = $client->messages->create(
$_REQUEST['To'],
array(
'from' => "YOUR_TWILIO_NUMBER",
'body' => $_REQUEST['Body']
)
);
echo "Sent message";
我向 follow the documentation 推荐完整的说明。