命令行中的SMS Twilio API错误,但浏览器中没有错误,但没有发送消息

侯赛姆·哈拉克(Hussam Hallak)

我现在twilio工作了一段时间,但是我想进行一些更改并将发送错误时附带的数字保存在数据库中,以避免再次发送错误,因此Twilio停止了工作。我从没有显示错误的浏览器中使用它,但是当我尝试从命令行运行脚本文件时遇到了这些错误。

任何帮助表示赞赏。

PHP Notice:  Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 80
PHP Notice:  Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 81
PHP Notice:  Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 82
PHP Notice:  Use of undefined constant CURLOPT_INFILESIZE - assumed 'CURLOPT_INFILESIZE' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 83
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 84
PHP Notice:  Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 85
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 89
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 89
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 89
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 89
PHP Notice:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 93
PHP Notice:  Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 106
PHP Notice:  Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 107
PHP Fatal error:  Call to undefined function Twilio\Http\curl_init() in /var/www/twilio/twilio-php-master/Twilio/Http/CurlClient.php on line 24


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Send SMS from parsed file</title>
</head>
<body>
<?php
ini_set("max_execution_time", 0);
$lines=array();
$fp=fopen('twilio_ready.csv', 'r');
while (!feof($fp)) {
    $line=fgets($fp);
    //Add +1 to the number
    $line='+1'.$line;
    //add to array
    $lines[]=$line;
}
fclose($fp);
unset($lines[count($lines)-1]);
$people =  array_flip($lines);

require_once __DIR__ . '/../twilio-php-master/Twilio/autoload.php'; // Loads the library
use Twilio\Twiml;
$servername = "localhost";
$username = "root";
$password = "lcrl62pk";
$dbname = "twilio";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);


use Twilio\Rest\Client;


    $AccountSid = "Something here";
    $AuthToken = "something here";

    // Step 3: instantiate a new Twilio Rest Client
    $client = new Client($AccountSid, $AuthToken);

    foreach ($people as $number => $name) {
                try {
                        $sms = $client->account->messages->create(

                                // the number we are sending to - Any phone number
                                $number,

                                array(
                                        // Step 6: Change the 'From' number below to be a valid Twilio number
                                        // that you've purchased
                                        'from' => "+1844444444",

                                        // the sms body
                                        'body' => "hey there"
                                )
                        );

                        // Display a confirmation message on the screen
                        echo "<font color='green'>Sent message to $name at phone number: $number.</font>"."<br />";
                } catch (Exception $e) {
                        echo "<font color='red'>Couldn't send message to $name at phone number: $number.</font>"."<br />";
                        //add them to black list database!
                }
    }



$conn->close();
print 'DONE!';
?>
</body>
</html>
侯赛姆·哈拉克(Hussam Hallak)

须藤apt-get install php5-curl

重新启动服务器:

sudo服务apache2重新启动

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

命令行中的转换命令错误

在PyCharm中运行命令行命令

netbeans mysql语法第1行出错,并且mysql查询浏览器中没有错误

尝试在Twilio SMS中创建短链接

mysql中的命令行

简单的<mat-option>不起作用。IDE或浏览器中没有错误

是否可以通过Linux命令行发送SMS消息?

为什么TypeScript在浏览器中没有显示错误?

Twilio SMS:有没有办法从SMS API和TwiML <message />响应生成的SMS中识别状态更新?

浏览器控制台中没有命令行解释器

在命令行中从*排除

命令行中的管道

我的junit测试中没有错误消息

在Python中,没有导入的命令行参数?

浏览器中没有响应错误,那是什么?

在浏览器的文件URL中输入许多斜杠时,为什么没有错误?

bash:为什么()在脚本中导致错误,但在命令行中却没有?

Python的命令行参数中没有后续值

插件中的错误使500服务器错误,屏幕或日志中没有错误消息

在脚本中停止命令行命令

c#命令行没有错误行号

Java 应用程序中出现 403 错误,但浏览器或 Postman 中没有

Angular 4:Authguard(canActivate) 没有像它应该的那样阻塞 url,破坏了应用程序阻塞的一切,控制台/浏览器中没有错误抛出

Twilio 无法拨打电话但没有错误

控制台没有错误,但无法在浏览器中查看阔叶商业版的管理模块

Python 脚本不会从命令行运行。它显示没有错误

蛇形中的命令行

未安装 gdal - jupyterlab 笔记本中的错误,但命令行中没有

如何在 selenium 中验证 UI 错误而没有错误消息