【问题标题】:How can I send SMS to mobile in local environment?如何在本地环境中向手机发送短信?
【发布时间】:2019-12-05 12:35:06
【问题描述】:

我想使用 php 向手机发送 SMS(文本消息)。该应用程序将部署在本地主机中。我来自罗马尼亚,欧洲。让我知道是否有任何实时免费软件 api 来实现这一点。我也可以购买付费版本。

【问题讨论】:

    标签: php localhost sms


    【解决方案1】:

    您可以使用 Twilio、Nexmo 等发送 SMS,甚至通过 localhost。 其中一些为您提供免费测试积分,但这仅用于测试目的。

    您可以使用他们的 API, 请参阅:-https://www.twilio.com/docs/usage/api 以获取更多参考。

    阅读文档,实现起来很简单。

    【讨论】:

    • DIR 。 '/供应商/autoload.php';使用 Twilio\Rest\Client; $account_sid = '添加'; $auth_token = '添加'; $twilio_number = "+15017122661"; $client = new Client($account_sid, $auth_token); $client->messages->create( // 向哪里发送短信(你的手机?) '+ added_myphonenumber', array( 'from' => $twilio_number, 'body' => '我在下面发送了这条消息10分钟!' ) ); ?>
    • 警告:要求(C:\wamp64\www\proiect-de-licenta/vendor/autoload.php):无法打开流:C:\wamp64\www\ 中没有这样的文件或目录proiect-de-licenta\indextest.php 在第 2 行
    • 致命错误:require():无法打开所需的 'C:\wamp64\www\proiect-de-licenta/vendor/autoload.php' (include_path='.;C:\php\pear ') 在 C:\wamp64\www\proiect-de-licenta\indextest.php 第 2 行
    • 你可以下载lumen框架来运行这段代码,别忘了运行composer。
    【解决方案2】:

    您可以使用以下网址:
    https://rapidapi.com/dimashirokov/api/Plivo
    首先检查 curl 示例,以便您得到正确的响应。
    下面是 curl 示例的代码:

    $api_key = '';
    $from = 'From name';
    $to = '123456789';
    $message = 'Test SMS';  
    $target_url="";
    $post = array('from' => $from,'to'=>$to,"message"=>$message,"api-key"=>$api_key);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $result=curl_exec ($ch);
    curl_close ($ch);
    echo $result;
    

    您需要为上述代码添加适当的数据,以便获得响应。

    【讨论】:

    • 你能给我一个发送短信的完整代码吗? (我将只更改电话号码),我从上面尝试了这个 cod,我也将 $to='my phone number here' 更改为,但没有任何反应,没有错误,没有短信
    【解决方案3】:

    您可以使用https://www.smslink.ro 上的 SMSLink API 在罗马尼亚发送短信。您可以选择 HTTP(S) GET / POST、SOAP / WSDL 或 JSON API,甚至是 Mail to SMS。

    【讨论】:

      猜你喜欢
      • 2012-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      相关资源
      最近更新 更多