C# Class Senparc.Weixin.MP.CommonAPIs.CommonApi

ファイルを表示 Open project: JeffreySu/WeiXinMPSDK Class Usage Examples

Public Methods

Method Description
CreateMenu ( string accessTokenOrAppId, ButtonGroup buttonData, int timeOut = Config.TIME_OUT ) : WxJsonResult

创建菜单

CreateMenu ( string accessTokenOrAppId, object buttonData, int timeOut = Config.TIME_OUT ) : WxJsonResult

创建菜单

CreateMenuConditional ( string accessTokenOrAppId, ConditionalButtonGroup buttonData, int timeOut = Config.TIME_OUT ) : CreateMenuConditionalResult

创建个新华菜单

DeleteMenu ( string accessTokenOrAppId ) : WxJsonResult

删除菜单

DeleteMenuConditional ( string accessTokenOrAppId, string menuId ) : WxJsonResult

删除菜单

GetCallBackIp ( string accessTokenOrAppId ) : GetCallBackIpResult

获取微信服务器的ip段

GetCallBackIpAsync ( string accessTokenOrAppId ) : Task

【异步方法】获取微信服务器的ip段

GetMenu ( string accessTokenOrAppId ) : GetMenuResult

获取当前菜单,如果菜单不存在,将返回null

GetMenuFromJsonResult ( GetMenuResultFull resultFull, ButtonGroupBase buttonGroupBase ) : GetMenuResult

根据微信返回的Json数据得到可用的GetMenuResult结果

GetTicket ( string appId, string secret, string type = "jsapi" ) : JsApiTicketResult

获取调用微信JS接口的临时票据

GetTicketAsync ( string appId, string secret, string type = "jsapi" ) : Task

【异步方法】获取调用微信JS接口的临时票据

GetTicketByAccessToken ( string accessTokenOrAppId, string type = "jsapi" ) : JsApiTicketResult

获取调用微信JS接口的临时票据

GetTicketByAccessTokenAsync ( string accessTokenOrAppId, string type = "jsapi" ) : Task

【异步方法】获取调用微信JS接口的临时票据

GetToken ( string appid, string secret, string grant_type = "client_credential" ) : AccessTokenResult

获取凭证接口

GetTokenAsync ( string appid, string secret, string grant_type = "client_credential" ) : Task

【异步方法】获取凭证接口

GetUserInfo ( string accessTokenOrAppId, string openId ) : WeixinUserInfoResult

用户信息接口

GetUserInfoAsync ( string accessTokenOrAppId, string openId ) : Task

【异步方法】用户信息接口

TryMatch ( string accessTokenOrAppId, string userId ) : MenuTryMatchResult

测试个性化菜单匹配结果

Private Methods

Method Description
GetButtonGroup ( List rootButtonList, ButtonGroupBase buttonGroup ) : void

从rootButtonList获取buttonGroup

GetMenuFromJson ( string jsonString ) : GetMenuResult
GetSingleButtonFromJsonObject ( object>.Dictionary objs ) : SingleClickButton

Method Details

CreateMenu() public static method

创建菜单
public static CreateMenu ( string accessTokenOrAppId, ButtonGroup buttonData, int timeOut = Config.TIME_OUT ) : WxJsonResult
accessTokenOrAppId string AccessToken或AppId。当为AppId时,如果AccessToken错误将自动获取一次。当为null时,获取当前注册的第一个AppId。
buttonData Senparc.Weixin.MP.Entities.Menu.ButtonGroup 菜单内容
timeOut int
return WxJsonResult

CreateMenu() public static method

创建菜单
public static CreateMenu ( string accessTokenOrAppId, object buttonData, int timeOut = Config.TIME_OUT ) : WxJsonResult
accessTokenOrAppId string AccessToken或AppId。当为AppId时,如果AccessToken错误将自动获取一次。当为null时,获取当前注册的第一个AppId。
buttonData object 菜单内容
timeOut int
return WxJsonResult

CreateMenuConditional() public static method

创建个新华菜单
public static CreateMenuConditional ( string accessTokenOrAppId, ConditionalButtonGroup buttonData, int timeOut = Config.TIME_OUT ) : CreateMenuConditionalResult
accessTokenOrAppId string AccessToken或AppId。当为AppId时,如果AccessToken错误将自动获取一次。当为null时,获取当前注册的第一个AppId。
buttonData Senparc.Weixin.MP.Entities.Menu.ConditionalButtonGroup 菜单内容
timeOut int
return Senparc.Weixin.MP.Entities.CreateMenuConditionalResult

DeleteMenu() public static method

删除菜单
public static DeleteMenu ( string accessTokenOrAppId ) : WxJsonResult
accessTokenOrAppId string
return WxJsonResult

DeleteMenuConditional() public static method

删除菜单
public static DeleteMenuConditional ( string accessTokenOrAppId, string menuId ) : WxJsonResult
accessTokenOrAppId string
menuId string 菜单Id
return WxJsonResult

GetCallBackIp() public static method

获取微信服务器的ip段
public static GetCallBackIp ( string accessTokenOrAppId ) : GetCallBackIpResult
accessTokenOrAppId string
return Senparc.Weixin.MP.Entities.GetCallBackIpResult

GetCallBackIpAsync() public static method

【异步方法】获取微信服务器的ip段
public static GetCallBackIpAsync ( string accessTokenOrAppId ) : Task
accessTokenOrAppId string
return Task

GetMenu() public static method

获取当前菜单,如果菜单不存在,将返回null
public static GetMenu ( string accessTokenOrAppId ) : GetMenuResult
accessTokenOrAppId string
return Senparc.Weixin.MP.Entities.GetMenuResult

GetMenuFromJsonResult() public static method

根据微信返回的Json数据得到可用的GetMenuResult结果
public static GetMenuFromJsonResult ( GetMenuResultFull resultFull, ButtonGroupBase buttonGroupBase ) : GetMenuResult
resultFull GetMenuResultFull
buttonGroupBase Senparc.Weixin.MP.Entities.Menu.ButtonGroupBase ButtonGroupBase的衍生类型,可以为ButtonGroup或ConditionalButtonGroup。返回的GetMenuResult中的menu属性即为此示例。
return Senparc.Weixin.MP.Entities.GetMenuResult

GetTicket() public static method

获取调用微信JS接口的临时票据
public static GetTicket ( string appId, string secret, string type = "jsapi" ) : JsApiTicketResult
appId string
secret string
type string 默认为jsapi,当作为卡券接口使用时,应当为wx_card
return Senparc.Weixin.MP.Entities.JsApiTicketResult

GetTicketAsync() public static method

【异步方法】获取调用微信JS接口的临时票据
public static GetTicketAsync ( string appId, string secret, string type = "jsapi" ) : Task
appId string
secret string
type string 默认为jsapi,当作为卡券接口使用时,应当为wx_card
return Task

GetTicketByAccessToken() public static method

获取调用微信JS接口的临时票据
public static GetTicketByAccessToken ( string accessTokenOrAppId, string type = "jsapi" ) : JsApiTicketResult
accessTokenOrAppId string
type string 默认为jsapi,当作为卡券接口使用时,应当为wx_card
return Senparc.Weixin.MP.Entities.JsApiTicketResult

GetTicketByAccessTokenAsync() public static method

【异步方法】获取调用微信JS接口的临时票据
public static GetTicketByAccessTokenAsync ( string accessTokenOrAppId, string type = "jsapi" ) : Task
accessTokenOrAppId string
type string 默认为jsapi,当作为卡券接口使用时,应当为wx_card
return Task

GetToken() public static method

获取凭证接口
public static GetToken ( string appid, string secret, string grant_type = "client_credential" ) : AccessTokenResult
appid string 第三方用户唯一凭证
secret string 第三方用户唯一凭证密钥,既appsecret
grant_type string 获取access_token填写client_credential
return Senparc.Weixin.MP.Entities.AccessTokenResult

GetTokenAsync() public static method

【异步方法】获取凭证接口
public static GetTokenAsync ( string appid, string secret, string grant_type = "client_credential" ) : Task
appid string 第三方用户唯一凭证
secret string 第三方用户唯一凭证密钥,既appsecret
grant_type string 获取access_token填写client_credential
return Task

GetUserInfo() public static method

用户信息接口
public static GetUserInfo ( string accessTokenOrAppId, string openId ) : WeixinUserInfoResult
accessTokenOrAppId string
openId string
return Senparc.Weixin.MP.Entities.WeixinUserInfoResult

GetUserInfoAsync() public static method

【异步方法】用户信息接口
public static GetUserInfoAsync ( string accessTokenOrAppId, string openId ) : Task
accessTokenOrAppId string
openId string
return Task

TryMatch() public static method

测试个性化菜单匹配结果
public static TryMatch ( string accessTokenOrAppId, string userId ) : MenuTryMatchResult
accessTokenOrAppId string
userId string 可以是粉丝的OpenID,也可以是粉丝的微信号。
return MenuTryMatchResult