0

I have only HTTP API for my SMS gateway for which I create an ASP.NET application to send SMS using ASP.NET page. The below string url is the HTTP API. Now, how to post this url in ASP.NET page to send SMS.

protected void Page_Load(object sender, EventArgs e)
    {
        string userk = "***********";
        string passk = "***********";
        string senderk = "someid";
        string phonek = "00000000000";
        string messagek = "This is a test API";
        string priorityk = "ndnd";
        string typek = "normal";
        string url = "http://indiansms.smsmaker.in/api/sendmsg.php?user=" + userk + "&pass=" + passk + "&sender=" + senderk + "&phone=" + phonek + "&text=" + messagek + "&priority=" + priorityk + "&stype=" + typek;
    }
4
  • Duplicate of ASP.NET SMS Gateway API, posted earlier by same user. Commented Sep 3, 2011 at 18:53
  • @Michael - Question is changed. Please reread the question. Also I just asked here how to post not to create an API for me. Moreover I didn't receive any relevant answer to my previous question. Commented Sep 3, 2011 at 18:55
  • You're trying to solve the same problem, just phrased differently. And "I didn't get a good answer" is not a reason to repost. Commented Sep 3, 2011 at 18:57
  • @Michael - I believe that SO users answering to this question is much easier than previous one as my previous question is incomplete. But if I edit my previous question due to timeout its getting back and nobody is looking at that question and that question will be left over as a question forever. Commented Sep 3, 2011 at 19:03

3 Answers 3

2

You can use the WebClient.UploadValues() method.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried using either WebRequest or WebClient? The fact that you're doing this from within an ASP.NET page is mostly irrelevant...

Note that you should escape URI parameters - otherwise you'll run into trouble with values such as a message of "hello & goodbye".

7 Comments

Thanks! this is working. but what do you mean by URI parameters?
@Kars: The username, message, priority etc - see Uri.EscapeUriString.
But what's the alternative? if I remove & how HTTP API differentiates values?
@Kars: You don't remove & - you use it as a delimiter, but escape it within values (along with other characters).
do you mean "&" + "pass" + passk " for "&pass=" + passk
|
0

Maybe using HttpWebRequest with preset data

        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://myurl");
        request.Method = "POST";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.