get的调用接口怎么写

mzwww 2019-07-16 10:04:02
253的功能接口说明
功能说明:此接口默认开通,回送地址服务器需要启动一个http服务用于接收上行短信。用户在收到上行短信后需要自己写个方法去做处理收到的参数。我们将为您实时推送回复的短信。
推送方式:GET
比如用户账户设置的上行短信回送地址为:http://client_url,那么当253平台收到运营商回送的上行短信后便会以get请求访问以下url:http://client_url?receiver=null&pswd=null&moTime=1811190759&mobile=18000000000&ms=短信内容&destcode=10690923&spCode=10690923¬ifyTime=181119075912

请问我要怎么写调用接口?谢谢
...全文
624 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mzwww 2019-07-16
  • 打赏
  • 举报
回复
非常感谢!谢谢老师
csdnFUCKINGSUCKS 2019-07-16
  • 打赏
  • 举报
回复
两种写法都可以

public void LoopBack()
{
    string receiver = Context.Request.QueryString["receiver"];
    string pswd = Context.Request.QueryString["pswd"];
    string moTime = Context.Request.QueryString["moTime"];
    string mobile = Context.Request.QueryString["mobile"];
    string ms = Context.Request.QueryString["ms"];
    string destcode = Context.Request.QueryString["destcode"];
    string spCode = Context.Request.QueryString["spCode"];
    string notifyTime = Context.Request.QueryString["notifyTime"];

    string s = string.Join(",", new { receiver, pswd, moTime, mobile, ms, destcode, spCode, notifyTime });

    Context.Response.Write(s);
}

[WebMethod]
public void LoopBack(string receiver, string pswd, string moTime, string mobile, string ms, string destcode, string spCode, string notifyTime)
{
    string s = string.Join(",", new { receiver, pswd, moTime, mobile, ms, destcode, spCode, notifyTime });

    Context.Response.Write(s);
}
注意在Web.config的system.web节点下加入

<webServices>
  <protocols>
    <add name="HttpGet"/>
  </protocols>
</webServices>
否则不支持get请求
mzwww 2019-07-16
  • 打赏
  • 举报
回复
[WebMethod]
public string Get253Message()
{
string receiver = Request.QueryString["receiver"];
string pswd = Request.QueryString["pswd"];
string moTime = Request.QueryString["moTime"];
string mobile = Request.QueryString["mobile"];
string ms = Request.QueryString["ms"];
string destcode = Request.QueryString["destcode"];
string spCode = Request.QueryString["spCode"];
string notifyTime = Request.QueryString["notifyTime"];

string s = string.Join(",", new { receiver, pswd, moTime, mobile, ms, destcode, spCode, notifyTime });
//可写可不写 这里只是为了输出效果
Response.Write(s);
}
webserver 没有Request,是不是?请赐教,怎么写?
csdnFUCKINGSUCKS 2019-07-16
  • 打赏
  • 举报
回复
引用 4 楼 的回复:
是webserver上写呢?
都可以 只要能给出一个可以访问的地址就行
mzwww 2019-07-16
  • 打赏
  • 举报
回复
是webserver上写呢?
csdnFUCKINGSUCKS 2019-07-16
  • 打赏
  • 举报
回复

public partial class LoopBack : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string receiver = Request.QueryString["receiver"];
            string pswd = Request.QueryString["pswd"];
            string moTime = Request.QueryString["moTime"];
            string mobile = Request.QueryString["mobile"];
            string ms = Request.QueryString["ms"];
            string destcode = Request.QueryString["destcode"];
            string spCode = Request.QueryString["spCode"];
            string notifyTime = Request.QueryString["notifyTime"];

            string s = string.Join(",", new { receiver, pswd, moTime, mobile, ms, destcode, spCode, notifyTime });
            //可写可不写 这里只是为了输出效果
            Response.Write(s);
        }
    }
}
mzwww 2019-07-16
  • 打赏
  • 举报
回复
public string Get253Message()
{
Stream s = System.Web.HttpContext.Current.Request.InputStream;
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
return "";
}
mzwww 2019-07-16
  • 打赏
  • 举报
回复
回送地址服务器需要启动一个http服务上,接口如何写?
[WebMethod]
public string Get253Message(string Url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "GET";
request.ContentType = "text/html;charset=UTF-8";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
return retString;
}

这样也不对啊

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧