ASP.NET SMS Gateway API

五迷三道 提交于 2019-12-08 09:18:12

问题


I purchased a SMS gateway for which they gave me only HTTP and XML API but I need ASP.NET API to work on my project. Can anybody help me how to convert the below API to ASP.NET(c#) API.

HTTP API

http://indiansms.smsmaker.in/api/sendmsg.php?user=*********&pass=********&sender=Sender ID&phone=Mobile No&text=SMS&priority=Priority&stype=smstype

XML API

$data="<?xml version='1.0' encoding='utf-8'?>
<MESSAGE>
<USERNAME>username</USERNAME>
<PASSWORD>password</PASSWORD>
<TEXT>Hi, this is a test message</TEXT>
<PRIORITY>ndnd</PRIORITY>
<SENDER>SenderId</SENDER>
<MSGTYPE>normal</MSGTYPE>
<ADDRESS>*********</ADDRESS>
<ADDRESS>*********</ADDRESS>
</MESSAGE>";

How to convert this API to ASP.NET API.

I know that this question is unqualified to post it here. But I need it immediately.


回答1:


I have done something similar from an .Net application where we used the http api to send sms. We used the webclient in .net to send messages.

    using (var client = new WebClient())
    {
        client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)");
        client.QueryString.Add("user", "username");
        client.QueryString.Add("pass", "password");
        // Add all the parameters you need

        using (Stream stream = client.OpenRead("http://indiansms.smsmaker.in/api/sendmsg.php"))
        {
            // Do something with the response..
        }
    }


来源:https://stackoverflow.com/questions/7294250/asp-net-sms-gateway-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!