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

查看:134
本文介绍了通过没有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函数中调用短信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 -调用sms网关restAPI的类文件
  • test.php -测试短信功能的示例文件.
  • sendsms.php - Class file to call sms gateway restAPI
  • test.php - Example file to test sms function.

该类使用的是Spring Edge短信网关提供商API,您可以根据需要为其他任何短信提供商自定义RestAPI URL和参数.

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天全站免登陆