我的php应用程序有一个新的短信服务。要发送消息,您需要转到带有数字和消息作为参数的URL。
这个短信服务很糟糕,来自我认识的外部公司:(
// example.com/sms/?c=number&m=message 的
通过一系列数据,我创建了一个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 ......
答案 0 :(得分:0)
我认为JavaScript不是一个好的解决方案。从它的声音,您想要调用该远程URL,以便您可以发送短信。您可以使用CURL或file_get_contents
并忽略结果(除非您需要结果)。