douxi3085 2013-07-02 16:42
浏览 67
已采纳

转到循环中的URL [多次]

I've got a new SMS service for my php app. To send a message you need to go to an URL with the number and message as parameters.

This sms service sucks, is from an external company I know :(

//example.com/sms/?c=number&m=message

With an array of data I made a foreach loop to send each message.

<?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);
}
?>

Now, ¿witch is the best way to go that URL in a loop [several times]? Header redirection doesn't work for me. Maybe cURL...

  • 写回答

1条回答 默认 最新

  • dongzhouji4021 2013-07-02 16:45
    关注

    I don't think JavaScript is a good solution. From the sound of it, you want to call that remote url so you can send an SMS. You can either use CURL or file_get_contents and just ignore the results (unless you need the results).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题