PHP Twilio应用程序-包括每个循环的SMS文件中断
我想不出来,所以我希望你能帮我一把 我正在创建一个twilio应用程序,并将整个文件包含在foreach循环中。但它不断打破我的循环,并且在运行后不会继续 它工作得很好,但包含在中的foreach在运行后将不会继续 有什么想法吗 谢谢, 尼克PHP Twilio应用程序-包括每个循环的SMS文件中断,php,loops,for-loop,foreach,twilio,Php,Loops,For Loop,Foreach,Twilio,我想不出来,所以我希望你能帮我一把 我正在创建一个twilio应用程序,并将整个文件包含在foreach循环中。但它不断打破我的循环,并且在运行后不会继续 它工作得很好,但包含在中的foreach在运行后将不会继续 有什么想法吗 谢谢, 尼克 我认为问题在于您在for循环中执行require。其中定义了一些对象,因此当您第二次需要它时,这些类将被再次定义,这将抛出一个错误 如果设置了error_reporting(E_ALL),那么您将在输出中看到这种效果的异常 我要么将其更改为require_
我认为问题在于您在for循环中执行require。其中定义了一些对象,因此当您第二次需要它时,这些类将被再次定义,这将抛出一个错误
如果设置了error_reporting(E_ALL),那么您将在输出中看到这种效果的异常
我要么将其更改为require_一次,要么将其移出for循环
我希望这有帮助
<?php
//shorten the URL
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$ebay_url);
// Include the PHP TwilioRest library
require "twilio/twilio.php";
// Twilio REST API version
$ApiVersion = "2010-04-01";
// Set our AccountSid and AuthToken
$AccountSid = "removed";
$AuthToken = "removed";
// Instantiate a new Twilio Rest Client
$client = new TwilioRestClient($AccountSid, $AuthToken);
// make an associative array of server admins
$people = array(
"removed"=>"Nick",
//"4158675310"=>"Helen",
//"4158675311"=>"Virgil",
);
// Iterate over all our server admins
foreach ($people as $number => $name) {
// Send a new outgoinging SMS by POST'ing to the SMS resource */
// YYY-YYY-YYYY must be a Twilio validated phone number
$response = $client->request("/$ApiVersion/Accounts/$AccountSid/SMS/Messages",
"POST", array(
"To" => $number,
"From" => 'removed',
"Body" => 'Alert! '.$title.' found for '. $price. '. View the item here: '.$tinyurl,
));
if($response->IsError)
echo "Error: {$response->ErrorMessage}\n";
else
echo "Sent message to: {$response->ResponseXml->SMSMessage->To}\n";
}
?>