PHP Examples to Send SMS, Receive SMS.|
This tutorial demostrates how it is possible to write PHP scripts/applications to send and receive SMS using VisualGSM Enterprise Server.
We shall go through 2 methods which you can use to send SMS through VisualGSM Enterprise:
1). Execute an SQL statement to insert the new message into VisualGSM LOGLOG table.
2). Issue an HTTP GET to VisualGSM Enterprise CSEND web API.
VisualGSM Enterprise can forward received SMS messages to your PHP script via HTTP GET.
Note:- For complete API parameters, please refer to the VisualGSM Enterprise API Guide.| |
1). VisualGSM Enterprise Server (SMS Gateway)
2). PHP 4 and Apache 1.2 (you may use higher versions)
3). Sample PHP scripts|
Example 1:- Creating a PHP script to send SMS by executing an SQL statement to insert the new message into VisualGSM LOGLOG table.| |
1. Install VisualGSM Enterprise Server.
If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.| |
2. PHP/Apache environment.
If you do not have PHP/Apache running on your server, you may download and installVisualGSM Web Service which installs Apache to Port 8000 and creates the Apache root under c:\vgsmweb\www\.
Download the Sample PHP Scripts and extract the folder php-samples and contents to to c:\vgsmweb\www\.| |
3. Configure and run PHP script.There are 3 PHP files, (mssql_insert_db.php,mysql_insert_db.php,oracle_insert_db.php) and 3 corresponding PHP configuration files (mssql_config.php, mysql_config.php, oracle_config.php) in library folder.
Select the configuration file which corresponds to the database you are using for VisualGSM Enterprise and amend the parameter user and password to your setup.For example, for SQL Server, please configure mssql_config.php:$dbhost='localhost'; #MSSQL host/ip address. $dbuser='sa';
$dbname='vgsmdb'; #VisualGSM database in MSSQL, default:VGSMDBAfter that, run mssql_insert_db.php from your web browser: http://127.0.0.1:8000/php-samples/mssql_insert_db.php
Note:-Please amend "127.0.0.1:8000" to the address of your Apache/PHP server.On success, you should get a return message "Successfully Inserted into Database".
Note: If you encounter a database error, please troubleshoot using the following steps:
i). Ensure that SQL Server service is running and your $dbhost is correct.
Uncomment extension=php_mssql.dll in php.ini by removing the semi-colon. If you are using VisualGSM Web Service, this is found in c:\vgsmweb\php\php.ini.
Next, copy php_mssql.dll ( c:\vgsmweb\php\extension\ folder or equivalent) to where the php binary is located - c:\vgsmweb\php\.
ii). If step (i) fails to resolve the error, find ntwdblib.dll on your MSSQL Server, and copy to where the php binary is located - c:\vgsmweb\php\ (You may also need to copy the file to c:\Windows\System32 as well). You may also obtain a copy of ntwdblib.dll from the VisualGSM Web Service installer.
Also ensure that your MSSQL accepts TCP/IP connections. Run SVRNETCN.exe in Bin folder of MSSQL. Select TCP/IP and Click on Enable. Click OK and then restart SQL Server.
i). Uncomment the lines: extension=php_oci8.dll, and extension=php_oracle.dll in php.ini by removing the semi-colon. If you are using VisualGSM Web Service, this is found in c:\vgsmweb\php\php.ini. Next, copy php_mssql.dll ( c:\vgsmweb\php\extension\ folder or equivalent) to where the php binary is located - c:\vgsmweb\php\.
Next, copy php_oci8.dll and php_oracle.dll ( c:\vgsmweb\php\extension\ folder or equivalent) to where the php binary is located - c:\vgsmweb\php\.| |
4. Start VisualGSM Service.
Start VisualGSM Service using the...