一键使用多个短信的问题

时间:2017-11-20 05:04:02

标签: php loops sms

有没有人可以帮助php循环? 我想一次发送多个短信。

这是我的代码:

<?php 
$ctx = stream_context_create(array( 
'http' => array( 
    'timeout' => 1 
    ) 
) 
); 
$from = $_POST["f"];
$too = $_POST["t"];
$text = urlencode($_POST['m']);
file_get_contents("http://www.example.com/api/sendSms.php?apiKey=xxxxxxx&charset=UTF-8&senderId=$from&mobile=$too&message=$text", 0, $ctx); 
?>

1 个答案:

答案 0 :(得分:0)

我假设你有一个拥有手机号码的阵列。

$ctx = stream_context_create(array( 
'http' => array( 
    'timeout' => 1 
    ) 
) 
); 
$from = $_POST["f"];
$too = explode(',',$_POST["t"]);  // array should be like [65882522,3366666,885555855]
$text = urlencode($_POST['m']);

foreach($too as $to ) {
    file_get_contents("http://www.example.com/api/sendSms.php?apiKey=xxxxxxx&charset=UTF-8&senderId=$from&mobile=$to&message=$text", 0, $ctx);

 }