i want to develop php application to send SMS through GSM modem in ubuntu os , i need a working sample code to connect successfully to the GSM modem and send messages through it .i tried some but it dint work.pls help me
thanks in advance
you first of all have to show your code before others could help.
download headwind gsm drive. then user the code below
$body="";
$addr=telephone;
$hgsmdrv = new COM("HeadwindGSM.SMSDriver") or die("Unable to open Headwind GSM Modem Driver");
// Connect to GSM modem
$hgsmdrv->Connect();
// Create message
$sms = new COM("HeadwindGSM.SMSMessage") or die("Unable to create SMS message");
$sms->To = $addr;
$sms->Body = $body;
// Send message
$sms->Send();
//free the objects
$hgsmdrv = null;
$sms = null;
hope that helps
Related
Is it possible to send a notification from php server side to Visual Basic or do I have to synchronize the server side database with the local database every x minutes to check for any changes?
<?php
require("connection.php");
include 'send_notification.php';
if (!$conn) {
$response["response"] = false;
$response["log"] = mysqli_error($conn);
$response["exception"] = 1;
echo json_encode($response);
} else {
$pricing = json_decode($_POST['pricing'], true);
$user = json_decode($_POST['user'], true);
// Here update database....
$company_token = getCompanyToken($user["id"]); // Find company token from MySql database to send FCM to Android Client
sendNotification($company_token); // Send Notification To Android...It works fine..
// Same notification to Visual Basic Windows Client...
// Help!! Synchronize local database with the server or is there any other way?
}
mysqli_close($conn);
}
?>
The only official SDKs for receiving messages from Firebase Cloud Messaging are for Android, iOS, and Web clients. Unless you are targeting one of these platforms, there is no SDK for receiving messages on VB.Net.
Also see:
How to receive push notifications from Firebase cloud messaging
Is it possible to receive FCM in .NET Core App (e.g. WPF Core client)
I'm using a device like this: https://www.google.com/search?q=GPRS+Modem&sxsrf=ACYBGNSaamI0HqEjZrM-ew59nRYv5lctEQ:1580550102344&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjt8Jj7h7DnAhWwUN4KHebwDy0Q_AUoAXoECA0QAw&biw=1536&bih=754
I want to send an SMS message using Phpserial class, I've already searched and followed some instructions on how to implement it. To make sure, I've downloaded an AT Tester to try sending message from my phone to my device and it was successful.
Now I want to implement it in PHP and I tried using Phpserial class. I am using windows OS and when I tried it, it returns no error but I didn't received any message. I tried to check console and network, it has no response and it returns no error i think?
Here is the code:
<?php
require('PhpSerial.php');
$num_send = $_POST['number'];
$txt = $_POST['txt_msg'];
$serial = new PhpSerial;
if($serial->deviceSet("COM4")){
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
if($serial->deviceOpen()){
$serial->sendMessage("AT+CMGF=1\n\r");
$serial->sendMessage("AT+cmgs=\"".$num_send."\"\n\r");
$serial->sendMessage(" ".$txt." \n\r");
$serial->sendMessage(chr(26));
//wait for modem to send message
sleep(7);
$read=$serial->readPort();
$serial->deviceClose();
echo "Success";
}
}
?>
The code above has no errors but I didn't received any message. Why ?
If use AT-Tester and success send,
You need the accepted command and Characters from GPRS device
best way sniff transfer packet from AT-Tester to GPRS Modem. Serial Port Monitor or freeserialanalyzer.com Free Best tools for detect the accepted command and Characters. Only generate liked packet monitored.
I m Trying to send a push notification to IOS Device.
My code like that for send a notification to ios device.
if($db_to[0]['platform']=='1') {
$messagesArray[]=array(
'DeviceToken'=>$db_to[0]['device_id'],
'Message'=>$msg,
'Sound'=>'default',
'noti_status'=>$db_to[0]['noti_status'],
'Type'=>'1',
'pid'=>$Promotion[0]['pid'],
'rest_id'=>$Promotion[0]['rest_id'] ,
'pnm'=>$Promotion[0]['pname'] ,
'pimg'=>$Promotion[0]['pimage'] ,
'pdesc'=>$Promotion[0]['pdesc'] ,
'p_bk_img'=>$Promotion[0]['p_background_img'] ,
'p_d_img'=>$Promotion[0]['p_detail_img'] ,
);
}
In PHP side I got these type of array when I printed the $messagesArray array.
But in IOS side he/she was got the different response like that.
aps = {
alert = "sent you a Notification";
sound = default;
type = 1;
};
So my Question is that , is there any changes in to the apns file or dataservice api files ???
IOS got only Type and Sound , and Notification Message which one I Send.
they didn't get the whole response which I was print it my side.
so Guys Please help me.
How can I Solve these.
Thanks in advance.
yes, which parameters you want in response just pass all parameters in function..
I have an app built with cordova and pushplugin, i receive the token from the device then i try to send a notification using a php server with the following code:
require_once 'ApnsPHP/Autoload.php';
// Instantiate a new ApnsPHP_Push object
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
'server_certificates.pem'
);
// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
// Connect to the Apple Push Notification Service
$push->connect();
// Instantiate a new Message with a single recipient
$message = new ApnsPHP_Message($regid);
// Set a simple welcome text
$message->setText("GELLLOOOOOO !! ");
// Play the default sound
$message->setSound();
// Add the message to the message queue
$push->add($message);
$push->send();
$push->disconnect();
$err = $push->getErrors() ;
echo "<pre>". var_dump($err) . "</pre>" ;
die("{}") ;
this code return no error in $err variable, I have absolutly no clue why this isn't working because it was working fine for a little moment i was able to get notifications on the device with the same code and same certificates and then it just decided to not work anymore.
If I have a GSM modem with 6 ports and each port inserted a SIM card,how can I send sms with random port?
Here is a simple code:
include "php_serial_class.php";
$serial=new phpSerial();
$serial->deviceSet("/dev/ttyUSB0");
$serial->deviceOpen();
//continue....
?>
So now the sms will sent through Port 1(ttyUSB0).What can I add or edit the script so that it can be sent with random port? Such as if Port 1 is busy or sending other sms then it will change to port 2...
I tried something like this:
if(!$serial->deviceOpen())
{
$serial->deviceSet("/dev/ttyUSB1");
}
and it won't works..
Thanks in advance.
You wouldn't know if device is busy unless you try to open it, so you have to check it one step with deviceOpen method. Example:
$ports = range(0,5);
shuffle($ports);
$serial = new phpSerial();
foreach($ports as $port){
if($serial->deviceSet("/dev/ttyUSB{$port}")){
if($serial->deviceOpen()){
// send sms
break; // break the loop after sending sms
}
}
}