我正在尝试设置 clickatell 以发送批量短信。我已经让它工作了,但它很慢。发送 5 条测试短信大约需要 20 秒,发送 10 条测试短信大约需要 30 秒。
$nums = array(
"44-227811116" => "1",
"44-227819885" => "2",
"44-227819314" => "3",
"44-227815413" => "4",
"44-227819326" => "5"
);
//login
$url="https://api.clickatell.com/http/auth?api_id=xxxxx&user=xxxxx&password=xxxxx";
$page=Utilities::getWebPage($url);
//session
$clicksessionparts=explode(":", $page);
$clicksession=trim($clicksessionparts[1]);
//batch
$from=xxxxx;
$batchTemplate = urlencode("Test message #field1#");
$url="https://api.clickatell.com/http_batch/startbatch?session_id=$clicksession&template=$batchTemplate&from=$from&deliv_ack=1";
$page=Utilities::getWebPage($url);
$batchId=explode(":",$page);
$batchId=trim($batchId[1]);
foreach ($nums as $k => $v)
{
$start = new DateTime();
print_r($start->format("H i:s"));
$url="https://api.clickatell.com/http_batch/senditem?session_id=$clicksession&batch_id=$batchId&to=xxxxx&field1=$v";
$page=Utilities::getWebPage($url);
echo "<pre>";
print_r($page);
echo "</pre>";
$end = new DateTime();
print_r($end->format("H i:s"));
echo "<br><br>";
}