如何使用twilio和Windows Scheduler发送短信?

时间:2019-02-07 19:41:44

标签: php sms twilio windows-scheduler

我想安排使用Twilio发送短信的时间。我目前可以使用Windows Scheduler计划何时运行php脚本,但是,每当我尝试使用twilio发送消息时,该脚本都不会执行。

使用twilio发送短信文本的PHP脚本

<?php
// Required if your environment does not handle autoloading
include '../vendor/autoload.php';

// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;

// Your Account SID and Auth Token from twilio.com/console
$sid = 'XXXXXXXXXXXXXXXXXXXXXXXXX';
$token = 'XXXXXXXXXXXXXXXXXXXXXXXXXX';
$client = new Client($sid, $token);

// Use the client to do fun stuff like send text messages!
$client->messages->create(
    // the number you'd like to send the message to
    '+19894837813',
    array(
        // A Twilio phone number you purchased at twilio.com/console
        'from' => '+19823837823',
        // the body of the text message you'd like to send
        'body' => 'Hey Jenny! Good luck on the bar exam!'
    )
);

?>

引用批处理文件的VB脚本

Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\xampp\htdocs\Twilio\php\script.bat" & Chr(34), 0
Set WinScriptHost = Nothing

调用php脚本的批处理文件

"C:\xampp\php\php.exe" -f "C:\xampp\htdocs\Twilio\php\index.php"

0 个答案:

没有答案