C#.net 微信公众账号接口开发
微信越来越火,微信公众平台成为开发成新宠,本文用C#.net开发微信公众信号接口。
微信接口地址代码:
weixin _wx = new weixin();
string postStr = "";
if (() == "post")
{
Stream s = ;
byte[] b = new byte[];
(b, 0, (int));
postStr = (b);
if (!(postStr)) //请求处理
{
(postStr);
}
}
else
{
();
}
微信处理类:
public class weixin
{
private string Token = "weixin_token"; //换成自己的token
public void Auth()
{
string echoStr = ["echoStr"];
if (CheckSignature())
{
if (!(echoStr))
{
(echoStr);
();
}
}
}
public void Handle(string postStr)
{
//封装请求类
XmlDocument doc = new XmlDocument();
(postStr);
XmlElement rootElement = ;
XmlNode MsgType = ("MsgType");
RequestXML requestXML = new RequestXML();
= ("ToUserName").InnerText;
= ("FromUserName").InnerText;
= ("CreateTime").InnerText;
= ;
if ( == "text")
{
= ("Content").InnerText;
}
else if ( == "location")
{
= ("Location_X").InnerText;
= ("Location_Y").InnerText;
= ("Scale").InnerText;
= ("Label").InnerText;
}
else if ( == "image")
{
= ("PicUrl").InnerText;
}
//回复消息
Resp
微信公众账号接口开发 来自淘豆网m.daumloan.com转载请标明出处.