Click here to Skip to main content
15,998,008 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use sms api, api detail given below, when i click on send button message show "Message Send Successfully" but message cannot send, kindly told me where i do mistake

1. Authentication & Session ID
In order to deliver a message, the system needs to authenticate the request as coming from a valid source.
The following parameters are used to achieve this:

msisdn: This is the Mobile Number for your Corporate Call & SMS Account
password: This is the current password you have set for your Account
You can have multiple threads open, however the session ID will expire after 30 minutes of inactivity. You will then have to re-authenticate to receive a new session ID.

Example:
Command:
https://sms.com:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx

Success Response:
XML
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Auth_request</command>
<data>Session ID</data>
<response>OK</response>
</corpsms>


Error Response:
XML
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Auth_request</command>
<data>Error Code</data>
<response>ERROR</response>
</corpsms>

NOTE: This Session ID must be used with all future commands to the API.

2. Sending a Quick Message
This command is used to send a Quick Message. To send a quick message, the destination address should be in the format 923xxxxxxxxx. The basic parameters required are:

session_id: The session ID returned from authentication
to: Comma separated list of destination mobile numbers
text: The content of the message
mask (optional): The mask to be used to send the message. If this parameter is not
present, then the default mask will be used
unicode (optional): If the text of the SMS is in any language other than English, this parameter must be sent to TRUE.
operator_id (optional): If the SMS is to be sent through a specific operator, this field should
contain ID for the respective operator.
List of operators is mentioned in Appendix D.
Each message returns a unique identifier in the form of Message ID.For multiple destination numbers, a
comma separated list of message ID's is returned. Single message ID is returned for each mobile number.
If even a single mobile number is in incorrect format, the request will be rejected. The message ID can be used
to track and monitor any given message. The message ID is returned after each post.

Example:
Command:
https://sms.com:27677/corporate_sms2/api/sendsms.jsp?session_id=xxxx&to=923xxxxxxxxx,923xx
xxxxxxx,923xxxxxxxxx&text=xxxx&mask=xxxx

Success Response:
XML
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Submit_SM</command>
<data>Message ID1,Message ID2,Message ID3</data>
<response>OK</response>
</corpsms>
Error Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Submit_SM</command>
<data>Error Code</data>
<response>ERROR</response>
</corpsms>


What I have tried:

C#
[HttpPost]
 public string SendSMS(string strNumber, string strMessage)
 {
   string Result = string.Empty;
   var plaintext = GetPlainTextFromHtml(strMessage);
WebRequest request = WebRequest.Create("https://sms.com:27677/corporate_sms2/api/sendsms.jsp?msisdn=SimNumber&password=PWD&to="+strNumber+"&text="+plaintext+"&mask=Masking Name");
            request.Method = "POST";
            //request.ContentType = "text/xml";
            request.ContentType = "text/xml;charset=UTF-8";
            //request.ContentType = "application/x-www-form-urlencoded";
            WebResponse response = request.GetResponse();
            if (((HttpWebResponse)response).StatusDescription.Equals("OK"))
            {
                Result = "Message Send Successfully";

            }
            response.Close();
            //var result;
            return Result;
        }
Posted
Updated 16-Jul-17 23:45pm
v4
Comments
[no name] 17-Jul-17 4:41am    
It's difficult to say without actually seeing the returned error. What is the actual message you get when it fails?
Member 10028394 17-Jul-17 6:44am    
my problem is solved, but new problem regarding this is that
i use the given below code
https://sms.com:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx
and get session_id
and use this session_id to send sms given below code
https://sms.com:27677/corporate_sms2/api/sendsms.jsp?session_id=xxxx&to=923xxxxxxxxx,923xx
xxxxxxx,923xxxxxxxxx&text=xxxx&mask=xxxx

Problem is this that this session id expire after 30 mints, i use this api to send sms automatically from web, and it is difficult to change session id again and again.

1 solution

Hi ,

Can you check the Sms.com API documentation whether this is GET or POST. If post then you have to change the above logic.
 
Share this answer
 
Comments
Member 10028394 17-Jul-17 6:46am    
my problem is solved, but new problem regarding this is that
i use the given below code
https://sms.com:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx
and get session_id
and use this session_id to send sms given below code
https://sms.com:27677/corporate_sms2/api/sendsms.jsp?session_id=xxxx&to=923xxxxxxxxx,923xx
xxxxxxx,923xxxxxxxxx&text=xxxx&mask=xxxx

Problem is this that this session id expire after 30 mints, i use this api to send sms automatically from web, and it is difficult to change session id again and again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900