protected override void ProcessResponseText(string responseText)
		{
			WeChatLoginInfo loginInfo = new WeChatLoginInfo();

			loginInfo.Error = responseText;
			WeChatLoginRetInfo retInfo = JSONSerializerExecute.Deserialize<WeChatLoginRetInfo>(responseText);

			retInfo.CheckResult();

			string token = string.Empty;

			if (retInfo.RedirectUrl.Length > 0)
			{
				if (retInfo.RedirectUrl.Contains("ok"))
				{
					token = retInfo.RedirectUrl.Split(new char[] { '&' })[2].Split(new char[] { '=' })[1].ToString();//取得令牌
					loginInfo.LoginCookie = this.Request.CookieContainer;
					loginInfo.CreateDate = DateTime.Now;
					loginInfo.Token = token;

					CookieCollection cookies = this.Request.CookieContainer.GetCookies(new Uri("https://mp.weixin.qq.com/"));

					if (cookies["slave_user"] != null)
						loginInfo.AccountID = cookies["slave_user"].Value;
				}
				else
				{
					throw new ApplicationException(retInfo.ToString());
				}
			}

			WeChatHelper.FillLoginInExtraInfo(loginInfo);

			this.LoginInfo = loginInfo;
		}
		public WeChatAddGroupExecutor(string name, WeChatLoginInfo loginInfo)
			: base("add", loginInfo)
		{
			name.CheckStringIsNullOrEmpty("name");

			this.Name = name;
		}
		public WeChatUpdateAppMessageExecutor(WeChatAppMessage message, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			message.NullCheck("message");

			this.Message = message;
		}
		public WeChatUploadFileExecutor(string filePath, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			filePath.CheckStringIsNullOrEmpty("filePath");

			this.FilePath = filePath;
		}
		public WeChatGetFriendMessagesExecutor(string fakeID, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			fakeID.CheckStringIsNullOrEmpty("toFakeID");

			this.FakeID = fakeID;
		}
		public WeChatGetAppMessagesExecutor(int pageIndex, int pageSize, WeChatAppMessageType messageType, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			this.PageIndex = pageIndex;
			this.PageSize = pageSize;
			this._MessageType = messageType;
		}
		public WeChatSingleSendImageMessageExecutor(string fakeID, string fileID, WeChatLoginInfo loginInfo)
			: base(fakeID, WeChatAppMessageType.Image, loginInfo)
		{
			fileID.CheckStringIsNullOrEmpty("fileID");

			this.FileID = fileID;
		}
		public WeChatDeleteGroupExecutor(int groupID, WeChatLoginInfo loginInfo)
			: base("del", loginInfo)
		{
			(groupID >= 0).FalseThrow("组号必须大于等于0");

			this.GroupID = groupID;
		}
		public WeChatModifyGroupExecutorBase(string func, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			func.CheckStringIsNullOrEmpty("func");

			this.FunctionName = func;
		}
		public WeChatMassSendAppMessageExecutor(int groupID, string appMsgID, WeChatLoginInfo loginInfo)
			: base(groupID, WeChatAppMessageType.Html, loginInfo)
		{
			appMsgID.IsNotEmpty().FalseThrow("待发送的消息ID不能为空");

			this.AppMessageID = appMsgID;
		}
		public WeChatGetGroupMembersExecutor(int groupID, int pageIndex, int pageSize, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			this.GroupID = groupID;
			this.PageIndex = pageIndex;
			this._PageSize = pageSize;
		}
		public WeChatSingleSendTextMessageExecutor(string fakeID, string content, WeChatLoginInfo loginInfo)
			: base(fakeID, WeChatAppMessageType.Text, loginInfo)
		{
			content.CheckStringIsNullOrEmpty("content");

			this.Content = content;
		}
		public WeChatMassSendImageMessageExecutor(int groupID, string fileID, WeChatLoginInfo loginInfo)
			: base(groupID, WeChatAppMessageType.Image, loginInfo)
		{
			fileID.IsNotEmpty().FalseThrow("待发送的图片ID不能为空");

			this.FileID = fileID;
		}
		public WeChatMassSendTextMessageExecutor(int groupID, string message, WeChatLoginInfo loginInfo)
			: base(groupID, WeChatAppMessageType.Text, loginInfo)
		{
			message.IsNotEmpty().FalseThrow("待发送的消息不能为空");

			this.Message = message;
		}
Exemplo n.º 15
0
		public static WeChatAppMessageCollection GetAppMessages(int pageIndex, int pageSize, WeChatAppMessageType messageType, WeChatLoginInfo loginInfo)
		{
			WeChatGetAppMessagesExecutor executor = new WeChatGetAppMessagesExecutor(pageIndex, pageSize, messageType, loginInfo);

			executor.Execute();

			return executor.AppMessages;
		}
Exemplo n.º 16
0
		public static WeChatAppMessage UpdateAppMessage(WeChatAppMessage message, WeChatLoginInfo loginInfo)
		{
			WeChatUpdateAppMessageExecutor executor = new WeChatUpdateAppMessageExecutor(message, loginInfo);

			executor.Execute();

			return executor.ResponseMessage;
		}
Exemplo n.º 17
0
		public static void FillLoginInExtraInfo(WeChatLoginInfo loginInfo)
		{
			loginInfo.NullCheck("loginInfo");

			WeChatGetLoginInExtraInfoExecutor executor = new WeChatGetLoginInExtraInfoExecutor(loginInfo);

			executor.Execute();
		}
Exemplo n.º 18
0
		/// <summary>
		/// 读取所有的组信息
		/// </summary>
		/// <param name="loginInfo"></param>
		/// <returns></returns>
		public static WeChatGroupCollection GetAllGroups(WeChatLoginInfo loginInfo)
		{
			WeChatGetAllGroupsExecutor executor = new WeChatGetAllGroupsExecutor(loginInfo);

			executor.Execute();

			return executor.AllGroups;
		}
		public WeChatChangeFriendsGroupExecutor(int groupID, string[] fakeIDs, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			fakeIDs.NullCheck("fakeIDs");

			this.GroupID = groupID;
			this.FakeIDs = fakeIDs;
		}
		public WeChatSingleSendMessageExecutorBase(string fakeID, WeChatAppMessageType messageType, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			fakeID.CheckStringIsNullOrEmpty("fakeID");

			this.FakeID = fakeID;
			this.MessageType = messageType;
		}
		public WeChatRenameGroupExecutor(int groupID, string name, WeChatLoginInfo loginInfo)
			: base("rename", loginInfo)
		{
			(groupID >= 0).FalseThrow("组号必须大于等于0");
			name.CheckStringIsNullOrEmpty("name");

			this.GroupID = groupID;
			this.Name = name;
		}
Exemplo n.º 22
0
		public static WeChatUploadFileRetInfo UploadFile(string filePath, WeChatLoginInfo loginInfo)
		{
			loginInfo.NullCheck("loginInfo");

			WeChatUploadFileExecutor executor = new WeChatUploadFileExecutor(filePath, loginInfo);

			executor.Execute();

			return executor.UploadedFileInfo;
		}
Exemplo n.º 23
0
		public static WeChatAppMessageCollection GetAppMessages(WeChatAppMessageType messageType, WeChatLoginInfo loginInfo)
		{
			return GetAppMessages(0, 20, messageType, loginInfo);
		}
Exemplo n.º 24
0
		public static WeChatModifyGroupRetInfo AddGroup(string name, WeChatLoginInfo loginInfo)
		{
			WeChatAddGroupExecutor executor = new WeChatAddGroupExecutor(name, loginInfo);

			executor.Execute();

			return executor.GroupInfo;
		}
Exemplo n.º 25
0
		public static WeChatModifyGroupRetInfo RenameGroup(int groupID, string name, WeChatLoginInfo loginInfo)
		{
			WeChatRenameGroupExecutor executor = new WeChatRenameGroupExecutor(groupID, name, loginInfo);

			executor.Execute();

			return executor.GroupInfo;
		}
Exemplo n.º 26
0
		public static WeChatModifyGroupRetInfo DeleteGroup(int groupID, WeChatLoginInfo loginInfo)
		{
			WeChatDeleteGroupExecutor executor = new WeChatDeleteGroupExecutor(groupID, loginInfo);

			executor.Execute();

			return executor.GroupInfo;
		}
Exemplo n.º 27
0
		public static void ChangeFriendsGroup(int groupID, string[] fakeIDs, WeChatLoginInfo loginInfo)
		{
			WeChatChangeFriendsGroupExecutor executor = new WeChatChangeFriendsGroupExecutor(groupID, fakeIDs, loginInfo);

			executor.Execute();
		}
		/// <summary>
		/// 群发消息基类
		/// </summary>
		/// <param name="groupID">groupID为-1时,表示发送范围为全部</param>
		/// <param name="messageType"></param>
		/// <param name="loginInfo"></param>
		public WeChatMassSendMessageExecutorBase(int groupID, WeChatAppMessageType messageType, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			this.GroupID = groupID;
			this.MessageType = messageType;
		}
Exemplo n.º 29
0
		/// <summary>
		/// 得到微信账号在某个组内的粉丝
		/// </summary>
		/// <param name="groupID">所属组的ID,如果小于0,则表示所有的用户</param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <param name="loginInfo"></param>
		/// <returns></returns>
		public static WeChatFriendCollection GetGroupMembers(int groupID, int pageIndex, int pageSize, WeChatLoginInfo loginInfo)
		{
			WeChatGetGroupMembersExecutor executor = new WeChatGetGroupMembersExecutor(groupID, pageIndex, pageSize, loginInfo);

			executor.Execute();

			return executor.Friends;
		}
		public WeChatGetRecentMessagesExecutor(int pageIndex, int pageSize, WeChatLoginInfo loginInfo)
			: base(loginInfo)
		{
			this.PageIndex = pageIndex;
			this.PageSize = pageSize;
		}