- Product Manual
- Introduction
- Installation Guide
- User Guide
- Developers Guide
- Tutorials
- ASP SMS API
- PHP SMS API
- HTTP SMS API
- SQL SMS API
- C# SMS API
- AJAX SMS API
- Delphi SMS API
- Cpp SMS API
- c HTTP SMS example
- Java SMS API
- VB.NET SMS API
- Python SMS API
- Perl SMS API
- TCL/TK SMS API
- Coldfusion SMS API
- VB 6 SMS API
- Examples and Solutions
- Appendix
- SMS FAQ
- Feature list
- Commercial Information
- Search
Ozeki brings you outstanding
SMS Gateway technology. Use our SMS Server products on Windows,Linux, or Android
C# SMS API
Developers can use our C# SMS API to send SMS from C#.Net. The C# SMS API comes with full source code
PHP SMS API
The ozeki PHP SMS gateway software can be used to send SMS from PHP and to receive SMS usig PHP on your website
SMPP SMS Gateway
SMS service providers use our SMPP gateway solution, that offers a high performance SMPP server and SMPP client gateway with amazing routing capabilities
Using the HTTP C++ SMS API
This is an example for Visual Studio 2008 developers on how to send SMS from C++ applications using HTTP request. The example is based on the Ozeki HTTP SMS API. For a higher performance C++ SMS source code, please visit the C++ SMS SDK that uses a TCP/IP socket to send and receive SMS messages.
Download: | cpp-sms-source-http.zip |
Introduction
The Ozeki HTTP SMS Api is an excellent solution to post SMS messages to the Ozeki NG SMS Gateway through the network. To use this solution first you need to install and configure Ozeki NG SMS Gateway in one of your computers, then you can use the example bellow to send SMS messages through it from any C++ application. This example posts SMS messages through HTTP to the gateway. The Ozeki gateway can convert these posts and forward your SMS messages through SMPP, CIMD2, UCP to SMS service providers or it can operate GSM modems to send your SMS messages using AT commands (Figure 1).
Source code for C++ SMS sending through HTTP
#include<iostream> #include<sstream> #include<windows.h> #include<wininet.h> using namespace std; string encode(string url); int main(int argc, char** argv) { // Ozeki NG SMS Gateway's host // and port. string host = "localhost"; int port = 9502; // Username // and password. string username = "admin"; string password = "abc123"; // Message string message = "Test message!"; // Originator's phone number. string originator = "+001111111"; // Recipient(s) phone number. // If You want to send message to multiple recipients, separate them with coma. // (don't use space character!) Ex: "+002222222,+003333333,+004444444" string recipient = "+002222222"; // Preparing the HTTPRequest url stringstream url; url << "/api?action=sendmessage&username=" << encode(username); url << "&password=" << encode(password); url << "&recipient=" << encode(recipient); url << "&messagetype=SMS:TEXT&messagedata=" << encode(message); url << "&originator=" << encode(originator); url << "&responseformat=xml"; // Create socket. HINTERNET inet = InternetOpen("Ozeki", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); // Open connection and bind it to the socket. HINTERNET conn = InternetConnect(inet, host.c_str() , port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); // Open the HTTP request HINTERNET sess = HttpOpenRequest(conn, "GET", url.str().c_str(), "HTTP/1.1", NULL, NULL, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0); // Check errors int error = GetLastError(); if(error == NO_ERROR) { // Send HTTP request. HttpSendRequest(sess, NULL, 0, NULL,0); // Receive HTTP response. int size = 1024; char *buffer = new char[size + 1]; DWORD read; int rsize = InternetReadFile(sess, (void *)buffer, size, &read); string s = buffer; s = s.substr(0, read); // Check statuscode int pos = s.find("<statuscode>0</statuscode>"); // If statuscode is 0, write "Message sent." to output // else write "Error." if(pos > 0) cout << "Message sent." << endl; else cout << "Error." << endl; } system("pause"); } // encoding converts characters that are not allowed in a URL into character-entity equivalent. string encode(string url) { char *hex = "0123456789abcdef"; stringstream s; for(unsigned int i = 0; i < url.length(); i++) { byte c = (char)url.c_str()[i]; if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') ){ s << c; } else { if(c == ' ') s << "%20"; else s << '%' << (hex[c >> 4]) << (hex[c & 15]); } } return s.str(); }
More information
- Developers Guide
- Ajax SMS API
- Delphi SMS API
- C++ SMS API
- C++ HTTP SMS example
- Java SMS API
- IIS Installing
- SQL SMS API
- HTTP SMS API
- C Sharp SMS API
- C Sharp SMS Gateway
- Feature list of the Ozeki NG SMS Gateway
- FAQ of the Ozeki NG SMS Gateway