/// <summary> /// 获取单个用户信息 /// </summary> /// <param name="weChatID"></param> /// <returns></returns> public static string GetUserInfo(string weChatID) { WeChatService.GetAccessToken(); string url = string.Format(WeChatService.Str_GetUserInfoUrl, WeChatService.Str_AccessToken, weChatID); string res = Http.DownloadString(url); return(res); }
/// <summary> /// 获取所有人员 /// </summary> /// <returns></returns> public static string GetAllUser() { WeChatService.GetAccessToken(); string url = string.Format(WeChatService.Str_GetAllUserUrl, WeChatService.Str_AccessToken); string data = Http.DownloadString(url); return(data); }
/// <summary> /// 发送文章 /// </summary> /// <param name="topicTitle"></param> /// <param name="subTitle"></param> /// <param name="picUrl"></param> /// <param name="articleUrl"></param> public static void SendArticle(string topicTitle, string subTitle, string picUrl, string articleUrl) { return; WeChatService.GetAccessToken(); string url = string.Format(WeChatService.Str_SendMessageUrl, WeChatService.Str_AccessToken); //string data = "{\"touser\": \"@all\",\"toparty\": \" \",\"totag\": \"\",\"msgtype\": \"news\",\"agentid\": \"1\",\"news\": {\"articles\":[{\"title\": \"WX_TITLE_WX\",\"description\": \"WX_DESCRIPTION_WX\",\"url\":\"WX_URL_WX\",\"picurl\": \"WX_PIC_URL_WX\"}]}}".Replace("WX_TITLE_WX", topicTitle).Replace("WX_DESCRIPTION_WX", subTitle).Replace("WX_URL_WX", articleUrl).Replace("WX_PIC_URL_WX", picUrl); string data = "{\"touser\": \"@all\",\"toparty\": \" \",\"totag\": \"\",\"msgtype\": \"news\",\"agentid\": \"1\",\"news\": {\"articles\":[{\"title\": \"WX_TITLE_WX\",\"description\": \"WX_DESCRIPTION_WX\",\"url\":\"WX_URL_WX\",\"picurl\": \"WX_PIC_URL_WX\"}]}}".Replace("WX_TITLE_WX", topicTitle).Replace("WX_DESCRIPTION_WX", subTitle).Replace("WX_URL_WX", articleUrl).Replace("WX_PIC_URL_WX", picUrl); //string res = Http.UploadString(url,"POST", data); }
/// <summary> /// 获取JSTicket /// </summary> /// <returns></returns> public static void GetJSTicket() { WeChatService.GetAccessToken(); if (WeChatService.Str_JSTicket == string.Empty) { string url = string.Format(WeChatService.Str_JSAPI, WeChatService.Str_AccessToken); string data = Http.DownloadString(url); WeChatService.Str_JSTicket = data.Replace("{\"errcode\":0,\"errmsg\":\"ok\",\"ticket\":\"", string.Empty).Replace("\",\"expires_in\":7200}", string.Empty); } }
/// <summary> /// 获取用户Code /// </summary> /// <param name="code"></param> /// <returns></returns> public static string GetWeChatID(string code) { if (!string.IsNullOrWhiteSpace(code)) { WeChatService.GetAccessToken(); string url = string.Format(WeChatService.Str_GetWeChatIDUrl, WeChatService.Str_AccessToken, code); string res = Http.DownloadString(url); Dictionary <string, object> data = serializer.Deserialize <Dictionary <string, object> >(res); return(data["UserId"].ToString()); } return(string.Empty); }