【问题标题】:twilio sms with pythontwilio 短信与 python
【发布时间】:2017-07-10 10:13:08
【问题描述】:

我希望将其转换为 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()

【问题讨论】:

  • 应用在swift3中,

标签: sms twilio


【解决方案1】:

这里是 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

【讨论】:

    猜你喜欢
    • 2018-02-14
    • 2022-06-14
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多