.net 微信接口(如何使用微信接口--做过的请进)
想做一个程序通过微信发信息。
有人做过吗?是怎么实现的。
-------------------------------------------------------------------
我找的参考代码,有人知道实现不步骤吗?
<%@ WebHandler Language="C#" CodeBehind="MessageReceiveHandler.ashx.cs" Class="MessageReceiveHandler" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using System.IO;
using Tencent.WeiXin;
/// <summary>
/// MessageReceiveHandler 的摘要说明
/// </summary>
public class MessageReceiveHandler : IHttpHandler
{
private static readonly string Token = "Opzoon-ITservice";
public void ProcessRequest(HttpContext context)
{
if (context.Request.RequestType == "GET")
{
if (CheckSignature(context))
{
context.Response.Write(context.Request.QueryString["echostr"]);
}
return;
}
var messageBase=MessageBase.Parse(context.Request.InputStream, context.Request.ContentEncoding);
Tencent.WeiXin.TextReplyMessage text = new Tencent.WeiXin.TextReplyMessage();
text.Content = "我收到了";
switch (messageBase.Type)
{
case MessageType.Text:
text.Content += string.Format("文本消息“{0}”",((TextMessage)messageBase).Content);break;