求助:关于微信发送信息出错

wkcode 2015-07-22 05:33:44
从网上下了个SDK,学习微信企业号,发送信息出了问题,请各位大神帮忙看下,万分感谢!
错误代码:
60011
no privilege to access/modify contact/party/agent


这是我写的发送代码

protected void Button6_Click(object sender, EventArgs e)
{
SendText bb = new SendText();
bb.Touser = "zhangsan";
bb.Agentid = 4;
bb.Msgtype = "text";
SendTextInfo cc = new SendTextInfo();
cc.Content = "你好";
bb.Text = cc;
SendReturnMsg aa = Dr.WechatHelper.API.SendMsgAPI.Send(bb, "E1BF1AFvBZFUotxjkexxxxxxxxxxxxduY3ps6IhNyQcuntYxnPfd64wKn8IAj2YMBS7ZrMofg");
Response.Write (aa.ErrorMessage);
}


这是SDK的发送API方法

public static SendReturnMsg Send(SendBase sendMsg, string accessToken)
{
try
{
string Returnstr = HttpWebHelper.Post(string.Format(Url, accessToken), JsonForObject.ParseToJsonFromObj(sendMsg));
return string.IsNullOrEmpty(Returnstr) ? null : JsonForObject.ParseToObjFromJson<SendReturnMsg>(Returnstr);
}
catch (Exception ex)
{
return new SendReturnMsg()
{
ErrorCode = -1,
ErrorMessage = "应用系统内部错误,错误为:" + ex.Message
};
}

}



这是SDK的SendBase类

/// <summary>
/// 发送客服消息(消息格式为JSON)
/// </summary>
[DataContract]
public class SendBase
{
/// <summary>
/// UserID列表(消息接收者,多个接收者用‘|’分隔)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
/// </summary>
[JsonProperty(PropertyName = "touser")]
public string Touser { get; set; }
/// <summary>
/// PartyID列表,多个接受者用‘|’分隔。当touser为@all时忽略本参数
/// </summary>
[JsonProperty(PropertyName = "toparty")]
public string Toparty { get; set; }
/// <summary>
/// TagID列表,多个接受者用‘|’分隔。当touser为@all时忽略本参数
/// </summary>
[JsonProperty(PropertyName = "totag")]
public string Totag { set; get; }
/// <summary>
/// 消息类型,文本为text,图片为image,语音为voice,视频为video,音乐为music,图文为news
/// </summary>
[JsonProperty(PropertyName = "msgtype")]
public string Msgtype { set; get; }
/// <summary>
/// 企业应用的id,整型。可在应用的设置页面查看
/// </summary>
[JsonProperty(PropertyName = "agentid")]
public int Agentid { get; set; }

}


/// <summary>
/// 发送文本消息
/// </summary>
[Serializable]
public class SendText : SendBase
{
public SendText()
{
base.Msgtype = "text";
}
/// <summary>
/// 内容
/// </summary>
[JsonProperty(PropertyName = "text")]
public SendTextInfo Text { get; set; }

}
/// <summary>
/// 文本详细
/// </summary>
[Serializable]
public class SendTextInfo
{
/// <summary>
/// 消息内容
/// </summary>
[JsonProperty(PropertyName = "content")]
public string Content { get; set; }
}


}
...全文
374 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
还想懒够 2015-07-24
  • 打赏
  • 举报
回复
http://blog.csdn.net/zhq426/article/details/42750555 参阅这个,看看是不是双引号出问题了
於黾 2015-07-24
  • 打赏
  • 举报
回复
都没说出了什么错误.让人上哪猜去

62,074

社区成员

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

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

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

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