我的php应用程序有了一个新的短信服务。要发送消息,您需要转到一个以数字和消息为参数的URL。
这个短信服务很糟糕,来自我认识的一家外部公司:(
//example.com/sms/?c=数字&m=消息
使用一组数据,我做了一个foreach循环来发送每条消息。
<?php
// Users array
$users[] = ['Jhon', 123456789]
$users[] = ['Peter', 223456789]
$users[] = ['Sam', 323456789]
$users[] = ['Carl', 423456789]
// The loop
foreach ($users as $thisUser) {
// URL builded with the users data
$thisNumber = $thisUser[1];
$thisMessage = 'Hey,+your+name+is+' . $thisUser[0]
$request = sprintf('http://example.com/sms/?c=%d&m=Hey+%s+', $thisNumber, $thisMessage);
}
?>
现在,切换是循环使用该URL的最佳方式[多次]?标头重定向对我不起作用。也许cURL。。。
我认为JavaScript不是一个好的解决方案。从声音上看,你想调用那个远程url,这样你就可以发送短信了。你可以使用CURL或file_get_contents
,然后忽略结果(除非你需要结果)。