2017-01-05 30 views
2

我有一段時間已經工作了一段時間,但我想進行一些更改並保存隨數據庫中的錯誤發送到的數字避免再次發送它們,並且不知何故,Twilio停止了工作。 我從瀏覽器中使用它顯示沒有錯誤,但當我試圖從命令行運行腳本文件時,我得到了這些錯誤。命令行中的SMS Twilio API錯誤但瀏覽器中沒有錯誤但未發送消息

任何幫助表示讚賞。

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> 
+0

你好像缺少捲曲的延伸。 – ceejayoz

+0

這是它的象徵。修復它通過這樣做:sudo apt-get install php5-curl 重新啓動服務器: sudo服務apache2重新啓動 –

回答

2

命令和apt-get安裝PHP5捲曲

重啓服務器:

須藤服務的Apache2重啓

+0

根據您的php版本和web服務器版本,使用以下命令。 sudo apt安裝php70-curl和sudo apachectl restart或sudo nginx -s在Ubuntu服務器上重新加載。 –

+0

這個包只是php-curl,例如sudo apt-get install php-curl。然後這將爲你的系統安裝正確的版本,例如使用上面的命令:'將安裝以下新軟件包:php-curl php7.2-curl' – Anthony

相關問題