在没有 GSM 的情况下通过 Arduino 发送短信 [英] Send SMS via Arduino without GSM

查看:29
本文介绍了在没有 GSM 的情况下通过 Arduino 发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Arduino 是否可以在不使用 GSM 屏蔽的情况下向互联网发送消息?

Is it possible for Arduino to send a message to the internet without using a GSM shield?

我需要一个 Arduino 来按下按钮发送消息,该按钮连接到 Arduino 和以太网扩展板,而不使用 GSM 扩展板.

I need an Arduino to send a message pressing a push button, which is connected to an Arduino and Ethernet shield, without using a GSM shield.

我需要通过 GET/POST 使用包含在服务器中的 HTML/PHP API 代码来发送消息.我在此代码中使用此代码将数据很好地插入到 SQL 数据库中,但如果成功插入数据,则通过 PHP API 发送短信.但它不起作用.这是我的 PHP 代码:

I need to send a message just by using HTML/PHP API code included in Server via GET/POST. I'm using this code in this code data nicely insert in SQL Database but if successfully insert data send sms via PHP API. But it's not working. Here is my PHP code:

<?php
  $mysqli = new mysqli("localhost", "user", "password","db");
  $tag=$_GET["value"];
  $result = $mysqli->query("INSERT INTO tag_tbl (tag_value, status) VALUES ('".$tag."', 1)");
  if ($result === false) {
    echo "SQL error:".$mysqli->error;
  } else {
    header("location: https://vas.banglalinksgsm.com/sendSMS/sendSMS?msisdn='xxxxx'&message='".$tag."'&userID=xxxxx&passwd=xxxxxx&sender=WSC");
  }
?>

推荐答案

您正在使用 header("location: xxx"); 可用于重定向到给定的 url.你可以在简单的 PHP 函数中调用 sms RestApi 来发送短信:

You are using header("location: xxx"); is usable to redirect to a given url. You can Call sms RestApi in simple PHP function to send sms:

function CURLsendsms($number, $message_body){
 $api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.'&message='.$textmessage;
 $smsGatewayUrl = "http://springedge.com";
 $smsgatewaydata = $smsGatewayUrl.$api_params;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_POST, false);
 curl_setopt($ch, CURLOPT_URL, smsgatewaydata);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $output = curl_exec($ch);
 curl_close($ch);
 // Use file get contents when CURL is not installed on server.
 if(!$output){
 $output =  file_get_contents($smsgatewaydata);  
 }
}

你也可以使用php类发送短信http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

Also you can use php class to send sms http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

上面的类中有两个文件:

There are two files in above class:

  • sendsms.php - 调用短信网关 restAPI 的类文件
  • test.php - 测试短信功能的示例文件.
  • sendsms.php - Class file to call sms gateway restAPI
  • test.php - Example file to test sms function.

这个类使用的是spring edge sms gateway provider API,您可以根据需要为任何其他sms provider自定义RestAPI url和params.

This Class is using spring edge sms gateway provider API you can customize RestAPI url and params for any other sms provider according to requirement.

这篇关于在没有 GSM 的情况下通过 Arduino 发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆