Skip to content

Commit

Permalink
Merge pull request #2607 from mc7246/master
Browse files Browse the repository at this point in the history
试用小程序接口及权限集更新
  • Loading branch information
JeffreySu authored Apr 2, 2022
2 parents 7bfda49 + 439214c commit aa649e9
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public static WxJsonResult FastRegisterWeApp(string componentAccessToken, string
public static FastRegisterPersonalWeAppResult FastRegisterPersonalWeApp(string componentAccessToken, string idName = "", string wxUser = "", string taskid = "", string action = "create", string componentPhone = "", int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/cgi-bin/component/fastregisterpersonalweapp?action={0}&component_access_token={1}",
Config.ApiMpHost + "/wxa/component/fastregisterpersonalweapp?action={0}&component_access_token={1}",
action.AsUrlData(),
componentAccessToken.AsUrlData());

Expand All @@ -395,6 +395,92 @@ public static FastRegisterPersonalWeAppResult FastRegisterPersonalWeApp(string c
return CommonJsonSend.Send<FastRegisterPersonalWeAppResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}

/// <summary>
/// 创建试用小程序
/// 文档:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastregister.html
/// </summary>
/// <param name="componentAccessToken"></param>
/// <param name="name">小程序名称,昵称半自动设定,强制后缀“的体验小程序”。且该参数会进行关键字检查,如果命中品牌关键字则会报错。如遇到品牌大客户要用试用小程序,建议用户先换个名字,认证后再修改成品牌名。只支持4-30个字符</param>
/// <param name="openid">微信用户的openid(不是微信号),试用小程序创建成功后会默认将该用户设置为小程序管理员。获取openid的方法请查看公众号获取openid</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static FastRegisterBetaWeAppResult FastRegisterBetaWeApp(string componentAccessToken, string name, string openid, int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/component/fastregisterbetaweapp?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
name = name,
openid = openid
};

return CommonJsonSend.Send<FastRegisterBetaWeAppResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}

/// <summary>
/// 试用小程序快速认证
/// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastverify.html
/// </summary>
/// <param name="componentAccessToken">第三方平台接口调用令牌authorizer_access_token</param>
/// <param name="entName">企业名(需与工商部门登记信息一致);如果是“无主体名称个体工商户”则填“个体户+法人姓名”,例如“个体户张三”</param>
/// <param name="entCode">企业代码</param>
/// <param name="legalPersonaWechat">法人微信号</param>
/// <param name="legalPersonaName">法人姓名(绑定银行卡)</param>
/// <param name="legalPersonaIDCard">法人身份证号</param>
/// <param name="codeType">企业代码类型 1:统一社会信用代码(18 位) 2:组织机构代码(9 位 xxxxxxxx-x) 3:营业执照注册号(15 位)</param>
/// <param name="componentPhone">第三方联系电话</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static WxJsonResult VerifyBetaWeApp(string componentAccessToken, string entName, string entCode, string legalPersonaWechat, string legalPersonaName, string legalPersonaIDCard, CodeType codeType = CodeType.统一社会信用代码, string componentPhone = "", int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/verifybetaweapp?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
verify_info = new
{
enterprise_name = entName,
code = entCode,
code_type = codeType,
legal_persona_wechat = legalPersonaWechat,
legal_persona_name = legalPersonaName,
legal_persona_idcard = legalPersonaIDCard,
component_phone = componentPhone
}
};

return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}

/// <summary>
/// 修改试用小程序名称
/// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastmodify.html
/// </summary>
/// <param name="componentAccessToken"></param>
/// <param name="name"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static WxJsonResult SetBetaWeAppNickName(string componentAccessToken, string name, int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/setbetaweappnickname?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
name = name
};

return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
}

/// <summary>
/// 拉取所有已授权的帐号信息
/// 文档:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/api_get_authorizer_list.html
Expand Down Expand Up @@ -787,7 +873,7 @@ public static async Task<WxJsonResult> FastRegisterWeAppAsync(string componentAc
public static async Task<FastRegisterPersonalWeAppResult> FastRegisterPersonalWeAppAsync(string componentAccessToken, string idName = "", string wxUser = "", string taskid = "", string action = "create", string componentPhone = "", int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/cgi-bin/component/fastregisterpersonalweapp?action={0}&component_access_token={1}",
Config.ApiMpHost + "/wxa/component/fastregisterpersonalweapp?action={0}&component_access_token={1}",
action.AsUrlData(),
componentAccessToken.AsUrlData());

Expand All @@ -813,6 +899,92 @@ public static async Task<FastRegisterPersonalWeAppResult> FastRegisterPersonalWe
return await CommonJsonSend.SendAsync<FastRegisterPersonalWeAppResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
}

/// <summary>
/// 【异步方法】创建试用小程序
/// 文档:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastregister.html
/// </summary>
/// <param name="componentAccessToken"></param>
/// <param name="name">小程序名称,昵称半自动设定,强制后缀“的体验小程序”。且该参数会进行关键字检查,如果命中品牌关键字则会报错。如遇到品牌大客户要用试用小程序,建议用户先换个名字,认证后再修改成品牌名。只支持4-30个字符</param>
/// <param name="openid">微信用户的openid(不是微信号),试用小程序创建成功后会默认将该用户设置为小程序管理员。获取openid的方法请查看公众号获取openid</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<FastRegisterBetaWeAppResult> FastRegisterBetaWeAppAsync(string componentAccessToken, string name, string openid, int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/component/fastregisterbetaweapp?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
name = name,
openid = openid
};

return await CommonJsonSend.SendAsync<FastRegisterBetaWeAppResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
}

/// <summary>
/// 【异步方法】试用小程序快速认证
/// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastverify.html
/// </summary>
/// <param name="componentAccessToken">第三方平台接口调用令牌authorizer_access_token</param>
/// <param name="entName">企业名(需与工商部门登记信息一致);如果是“无主体名称个体工商户”则填“个体户+法人姓名”,例如“个体户张三”</param>
/// <param name="entCode">企业代码</param>
/// <param name="legalPersonaWechat">法人微信号</param>
/// <param name="legalPersonaName">法人姓名(绑定银行卡)</param>
/// <param name="legalPersonaIDCard">法人身份证号</param>
/// <param name="codeType">企业代码类型 1:统一社会信用代码(18 位) 2:组织机构代码(9 位 xxxxxxxx-x) 3:营业执照注册号(15 位)</param>
/// <param name="componentPhone">第三方联系电话</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<WxJsonResult> VerifyBetaWeAppAsync(string componentAccessToken, string entName, string entCode, string legalPersonaWechat, string legalPersonaName, string legalPersonaIDCard, CodeType codeType = CodeType.统一社会信用代码, string componentPhone = "", int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/verifybetaweapp?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
verify_info = new
{
enterprise_name = entName,
code = entCode,
code_type = codeType,
legal_persona_wechat = legalPersonaWechat,
legal_persona_name = legalPersonaName,
legal_persona_idcard = legalPersonaIDCard,
component_phone = componentPhone
}
};

return await CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
}

/// <summary>
/// 【异步方法】修改试用小程序名称
/// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastmodify.html
/// </summary>
/// <param name="componentAccessToken"></param>
/// <param name="name"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task< WxJsonResult> SetBetaWeAppNickNameAsync(string componentAccessToken, string name, int timeOut = Config.TIME_OUT)
{
var url = string.Format(
Config.ApiMpHost + "/wxa/setbetaweappnickname?access_token={0}",
componentAccessToken.AsUrlData());

//var data;
object data = new
{
name = name
};

return await CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
}

/// <summary>
/// 【异步方法】拉取所有已授权的帐号信息
/// 文档:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/api_get_authorizer_list.html
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#region Apache License Version 2.0
/*----------------------------------------------------------------
Copyright 2022 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
----------------------------------------------------------------*/
#endregion Apache License Version 2.0

/*----------------------------------------------------------------
Copyright (C) 2022 Senparc
文件名:FastRegisterBetaWeAppResult.cs
文件功能描述:创建试用小程序接口返回结果
创建标识: mc7246 - 20220329
----------------------------------------------------------------*/

using Senparc.Weixin.Entities;
using System;

namespace Senparc.Weixin.Open.ComponentAPIs
{
/// <summary>
/// 创建试用小程序接口返回结果
/// </summary>
[Serializable]
public class FastRegisterBetaWeAppResult : WxJsonResult
{
/// <summary>
/// 该请求的唯一标识符,用于关联微信用户和后面产生的appid
/// </summary>
public string unique_id { get; set; }

/// <summary>
/// 用户授权确认url,需将该url发送给用户,用户进入授权页面完成授权方可创建小程序
/// </summary>
public string authorize_url { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*----------------------------------------------------------------
Copyright (C) 2022 Senparc
文件名:RequestMessageFastRegisterBetaAppApp.cs
文件功能描述:创建试用小程序事件推送
创建标识:mc7246 - 20220329
----------------------------------------------------------------*/

using Senparc.NeuChar.Entities;
using System;

namespace Senparc.Weixin.Open
{
/// <summary>
/// 创建试用小程序事件推送
/// </summary>
public class RequestMessageFastRegisterBetaAppApp : RequestMessageBase
{
public override RequestInfoType InfoType
{
get { return RequestInfoType.notify_third_fastregisterbetaapp; }
}

/// <summary>
/// 创建小程序appid
/// </summary>
public string appid { get; set; }

public ReturnCode status { get; set; }

public string msg { get; set; }

public ThirdFastRegisterBetaAppInfo info {get;set;}
}

public class ThirdFastRegisterBetaAppInfo
{
/// <summary>
/// 唯一标识符
/// </summary>
public string unique_id { get; set; }

/// <summary>
/// 小程序名称
/// </summary>
public string name { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*----------------------------------------------------------------
Copyright (C) 2022 Senparc
文件名:RequestMessageFastVerifyBetaApp.cs
文件功能描述:试用小程序快速认证事件推送
创建标识:mc7246 - 20220329
----------------------------------------------------------------*/

using Senparc.NeuChar.Entities;
using System;

namespace Senparc.Weixin.Open
{
/// <summary>
/// 试用小程序快速认证事件推送
/// </summary>
public class RequestMessageFastVerifyBetaApp : RequestMessageBase
{
public override RequestInfoType InfoType
{
get { return RequestInfoType.notify_third_fastverifybetaapp; }
}

/// <summary>
/// 创建小程序appid
/// </summary>
public string appid { get; set; }

public ReturnCode status { get; set; }

public string msg { get; set; }

/// <summary>
/// 注册时提交的资料
/// </summary>
public ThirdFasteRegisterInfo info {get;set;}
}
}
Loading

0 comments on commit aa649e9

Please sign in to comment.