private string client_OnUserFollow(object sender, EventArgs e) { NameValueCollection param = new NameValueCollection { HttpContext.Current.Request.Form, HttpContext.Current.Request.QueryString }; try { AlipayOHClient alipayOHClient = (AlipayOHClient)sender; SiteSettings masterSettings = SettingsManager.GetMasterSettings(); Articles articles = new Articles { Item = new Item { Description = masterSettings.AliOHFollowRelay, Title = (string.IsNullOrWhiteSpace(masterSettings.AliOHFollowRelayTitle) ? "欢迎您的关注!" : masterSettings.AliOHFollowRelayTitle) } }; IRequest request = new MessagePushRequest(alipayOHClient.request.AppId, alipayOHClient.request.FromUserId, articles, 1, null, "image-text"); AlipayOHClient alipayOHClient2 = new AlipayOHClient(masterSettings.AliOHServerUrl, alipayOHClient.request.AppId, this.alipayPubKeyFile, this.priKeyFile, this.pubKeyFile, "UTF-8"); MessagePushResponse messagePushResponse = alipayOHClient2.Execute <MessagePushResponse>(request); } catch (Exception ex) { Globals.WriteExceptionLog_Page(ex, param, "alipay.ashx"); } return(""); }
public void ProcessRequest(HttpContext context) { string text1 = context.Request["EventType"]; this.priKeyFile = context.Server.MapPath("~/config/rsa_private_key.pem"); this.alipayPubKeyFile = context.Server.MapPath("~/config/alipay_pubKey.pem"); this.pubKeyFile = context.Server.MapPath("~/config/rsa_public_key.pem"); this.logfile = context.Server.MapPath("~/a.log"); AlipayOHClient client = new AlipayOHClient(this.alipayPubKeyFile, this.priKeyFile, this.pubKeyFile, "UTF-8"); client.OnUserFollow += new OnUserFollow(this.client_OnUserFollow); client.HandleAliOHResponse(context); }
private string client_OnUserFollow(object sender, EventArgs e) { try { AlipayOHClient client = (AlipayOHClient)sender; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); Articles articles2 = new Articles(); Item item = new Item { Description = masterSettings.AliOHFollowRelay, Title = string.IsNullOrWhiteSpace(masterSettings.AliOHFollowRelayTitle) ? "欢迎您的关注!" : masterSettings.AliOHFollowRelayTitle }; articles2.Item = item; Articles articles = articles2; IRequest request = new MessagePushRequest(client.request.AppId, client.request.FromUserId, articles, 1, null, "image-text"); new AlipayOHClient(masterSettings.AliOHServerUrl, client.request.AppId, this.alipayPubKeyFile, this.priKeyFile, this.pubKeyFile, "UTF-8").Execute <MessagePushResponse>(request); } catch (Exception) { } return(""); }
private void btnSubmit_Click(object sender, EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (string.IsNullOrEmpty(masterSettings.AliOHAppId)) { base.Response.Write("<script>alert('您的服务号配置存在问题,请您先检查配置!');location.href='AliOHServerConfig.aspx'</script>"); } else { IList <MenuInfo> initMenus = VShopHelper.GetInitMenus(ClientType.AliOH); List <Hishop.Alipay.OpenHome.Model.Button> list = new List <Hishop.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo item in initMenus) { if (item.Chilren == null || item.Chilren.Count == 0) { list.Add(new Hishop.Alipay.OpenHome.Model.Button { name = item.Name, actionParam = (string.IsNullOrEmpty(item.Url) ? "http://javasript:;" : item.Url), actionType = item.Type }); } else { Hishop.Alipay.OpenHome.Model.Button button = new Hishop.Alipay.OpenHome.Model.Button { name = item.Name }; List <Hishop.Alipay.OpenHome.Model.Button> list2 = new List <Hishop.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo item2 in item.Chilren) { list2.Add(new Hishop.Alipay.OpenHome.Model.Button { name = item2.Name, actionParam = (string.IsNullOrEmpty(item2.Url) ? "http://javasript:;" : item2.Url), actionType = item2.Type }); } button.subButton = list2; list.Add(button); } } Hishop.Alipay.OpenHome.Model.Menu menu = new Hishop.Alipay.OpenHome.Model.Menu { button = list }; AlipayOHClient alipayOHClient = AliOHClientHelper.Instance(base.Server.MapPath("~/")); bool flag = false; try { AddMenuRequest request = new AddMenuRequest(menu); MenuAddResponse menuAddResponse = alipayOHClient.Execute <MenuAddResponse>(request); this.ShowMsg("保存到生活号(原支付宝服务窗)成功!", true); flag = true; } catch (AliResponseException ex) { Globals.WriteExceptionLog_Page(ex, this.pageparam, "AliohMenuSave"); } catch (Exception ex2) { this.ShowMsg("保存到生活号失败,失败原因:" + ex2.Message, false); flag = true; Globals.WriteExceptionLog_Page(ex2, this.pageparam, "AliohMenuSave"); } if (!flag) { try { UpdateMenuRequest request2 = new UpdateMenuRequest(menu); MenuUpdateResponse menuUpdateResponse = alipayOHClient.Execute <MenuUpdateResponse>(request2); this.ShowMsg("保存到生活号成功!", true); } catch (Exception ex3) { this.ShowMsg("保存到生活号失败,失败原因:" + ex3.Message, false); Globals.WriteExceptionLog_Page(ex3, this.pageparam, "AliohMenuSave"); } } } }
private void btnSubmit_Click(object sender, System.EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (string.IsNullOrEmpty(masterSettings.AliOHAppId)) { base.Response.Write("<script>alert('您的服务号配置存在问题,请您先检查配置!');location.href='AliOHServerConfig.aspx'</script>"); return; } System.Collections.Generic.IList <MenuInfo> initMenus = VShopHelper.GetInitMenus(ClientType.AliOH); System.Collections.Generic.List <Ecdev.Alipay.OpenHome.Model.Button> list = new System.Collections.Generic.List <Ecdev.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo current in initMenus) { if (current.Chilren == null || current.Chilren.Count == 0) { list.Add(new Ecdev.Alipay.OpenHome.Model.Button { name = current.Name, actionParam = string.IsNullOrEmpty(current.Url) ? "http://javasript:;" : current.Url, actionType = current.Type }); } else { Ecdev.Alipay.OpenHome.Model.Button button = new Ecdev.Alipay.OpenHome.Model.Button { name = current.Name }; System.Collections.Generic.List <Ecdev.Alipay.OpenHome.Model.Button> list2 = new System.Collections.Generic.List <Ecdev.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo current2 in current.Chilren) { list2.Add(new Ecdev.Alipay.OpenHome.Model.Button { name = current2.Name, actionParam = string.IsNullOrEmpty(current2.Url) ? "http://javasript:;" : current2.Url, actionType = current2.Type }); } button.subButton = list2; list.Add(button); } } Ecdev.Alipay.OpenHome.Model.Menu menu = new Ecdev.Alipay.OpenHome.Model.Menu { button = list }; AlipayOHClient alipayOHClient = AliOHClientHelper.Instance(base.Server.MapPath("~/")); bool flag = false; try { AddMenuRequest request = new AddMenuRequest(menu); alipayOHClient.Execute <MenuAddResponse>(request); this.ShowMsg("保存到服务窗成功!", true); flag = true; } catch (AliResponseException) { } catch (System.Exception ex) { this.ShowMsg("保存到服务窗失败,失败原因:" + ex.Message, false); flag = true; } if (!flag) { try { UpdateMenuRequest request2 = new UpdateMenuRequest(menu); alipayOHClient.Execute <MenuUpdateResponse>(request2); this.ShowMsg("保存到服务窗成功!", true); } catch (System.Exception ex2) { this.ShowMsg("保存到服务窗失败,失败原因:" + ex2.Message, false); } } }
public static AlipaySystemOauthTokenResponse GetOauthTokenResponse(string auth_code) { AlipayOHClient client = new AlipayOHClient(AlipayFuwuConfig.serverUrl, AlipayFuwuConfig.appId, AlipayFuwuConfig.alipay_public_key, AlipayFuwuConfig.merchant_private_key, AlipayFuwuConfig.merchant_public_key, "UTF-8"); return(client.OauthTokenRequest(auth_code)); }
public static AlipayUserUserinfoShareResponse GetAlipayUserUserinfo(string AccessToken) { AlipayOHClient client = new AlipayOHClient(AlipayFuwuConfig.serverUrl, AlipayFuwuConfig.appId, AlipayFuwuConfig.alipay_public_key, AlipayFuwuConfig.merchant_private_key, AlipayFuwuConfig.merchant_public_key, "UTF-8"); return(client.GetAliUserInfo(AccessToken)); }
private void btnSubmit_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(SettingsManager.GetMasterSettings(false).AliOHAppId)) { base.Response.Write("<script>alert('您的服务号配置存在问题,请您先检查配置!');location.href='AliOHServerConfig.aspx'</script>"); } else { IList <MenuInfo> initMenus = VShopHelper.GetInitMenus(ClientType.AliOH); List <Hishop.Alipay.OpenHome.Model.Button> list2 = new List <Hishop.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo info in initMenus) { if ((info.Chilren == null) || (info.Chilren.Count == 0)) { Hishop.Alipay.OpenHome.Model.Button item = new Hishop.Alipay.OpenHome.Model.Button { name = info.Name, actionParam = string.IsNullOrEmpty(info.Url) ? "http://javasript:;" : info.Url, actionType = info.Type }; list2.Add(item); } else { Hishop.Alipay.OpenHome.Model.Button button2 = new Hishop.Alipay.OpenHome.Model.Button { name = info.Name }; List <Hishop.Alipay.OpenHome.Model.Button> list3 = new List <Hishop.Alipay.OpenHome.Model.Button>(); foreach (MenuInfo info2 in info.Chilren) { Hishop.Alipay.OpenHome.Model.Button button3 = new Hishop.Alipay.OpenHome.Model.Button { name = info2.Name, actionParam = string.IsNullOrEmpty(info2.Url) ? "http://javasript:;" : info2.Url, actionType = info2.Type }; list3.Add(button3); } button2.subButton = list3; list2.Add(button2); } } Hishop.Alipay.OpenHome.Model.Menu menu = new Hishop.Alipay.OpenHome.Model.Menu { button = list2 }; AlipayOHClient client = AliOHClientHelper.Instance(base.Server.MapPath("~/")); bool flag = false; try { AddMenuRequest request = new AddMenuRequest(menu); client.Execute <MenuAddResponse>(request); this.ShowMsg("保存到服务窗成功!", true); flag = true; } catch (AliResponseException) { } catch (Exception exception) { this.ShowMsg("保存到服务窗失败,失败原因:" + exception.Message, false); flag = true; } if (!flag) { try { UpdateMenuRequest request2 = new UpdateMenuRequest(menu); client.Execute <MenuUpdateResponse>(request2); this.ShowMsg("保存到服务窗成功!", true); } catch (Exception exception2) { this.ShowMsg("保存到服务窗失败,失败原因:" + exception2.Message, false); } } } }