コード例 #1
0
        /// <summary>
        /// 7、设置授权方的选项信息
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="component_access_token"></param>
        /// <param name="component_appid">第三方平台appid</param>
        /// <param name="authorizer_appid">授权公众号appid</param>
        /// <param name="option_name">选项名称</param>
        /// <returns></returns>
        public static MpResult SetAuthorizerOption(this MpHelper helper, string component_access_token,
                                                   string component_appid, string authorizer_appid, string option_name)
        {
            string url = string.Format("{0}cgi-bin/component/api_set_authorizer_option?component_access_token={1}", baseurl, component_access_token);

            return(HttpHelper.Send <dynamic, MpResult>(url, new { component_appid = component_appid, authorizer_appid = authorizer_appid, option_name = option_name }));
        }
コード例 #2
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="helper"></param>
        ///// <param name="access_token"></param>
        ///// <param name="openId"></param>
        ///// <returns></returns>
        //public static GetUserInfoResult GetSNSUserInfo(this MpHelper helper, string access_token, string openId)
        //{
        //    string url = string.Format("{0}sns/userinfo?access_token={1}&openid={2}", baseurl, access_token, openId);
        //    return HttpHelper.HttpGet.GetJsonResult<GetUserInfoResult>(url);
        //}

        /// <summary>
        /// 1、获取第三方平台access_token
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="component_appid">第三方平台appid</param>
        /// <param name="component_appsecret">第三方平台appsecret</param>
        /// <param name="verify_ticket">微信后台推送的ticket,此ticket会定时推送,具体请见本页末尾的推送说明</param>
        /// <returns></returns>
        public static GetComponentAccessTokenResult GetComponentAccessToken(this MpHelper helper, string component_appid, string component_appsecret, string verify_ticket)
        {
            string url = string.Format("{0}cgi-bin/component/api_component_token", baseurl);

            return(HttpHelper.HttpPost.GetJsonResult <dynamic, GetComponentAccessTokenResult>(url,
                                                                                              new
            {
                component_appid = component_appid,
                component_appsecret = component_appsecret,
                verify_ticket = verify_ticket
            }));
        }
コード例 #3
0
        /// <summary>
        /// 5、获取授权方信息
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="component_access_token"></param>
        /// <param name="component_appid">服务appid</param>
        /// <param name="authorizer_appid">授权方appid</param>
        /// <returns></returns>
        public static GetAuthorizerInfoResult GetAuthorizerInfo(this MpHelper helper, string component_access_token,
                                                                string component_appid, string authorizer_appid)
        {
            string url = string.Format("{0}cgi-bin/component/api_authorizer_token?component_access_token={1}", baseurl, component_access_token);

            return(HttpHelper.HttpPost.GetJsonResult <dynamic, GetAuthorizerInfoResult>(url,
                                                                                        new
            {
                component_appid = component_appid,
                authorizer_appid = authorizer_appid,
            }));
        }
コード例 #4
0
        /// <summary>
        /// 3、使用授权码换取公众号的授权信息
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="component_access_token"></param>
        /// <param name="component_appid">第三方平台appid</param>
        /// <param name="authorization_code">授权code,会在授权成功时返回给第三方平台,详见第三方平台授权流程说明</param>
        /// <returns></returns>
        public static QueryComponentAuthResult QueryComponentAuth(this MpHelper helper, string component_access_token, string component_appid, string authorization_code)
        {
            string url = string.Format("{0}cgi-bin/component/api_query_auth?component_access_token={1}", baseurl, component_access_token);

            return(HttpHelper.HttpPost.GetJsonResult <dynamic, QueryComponentAuthResult>(url, new { component_appid = component_appid, authorization_code = authorization_code }));
        }
コード例 #5
0
        /// <summary>
        /// 2、获取预授权码
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="component_access_token"></param>
        /// <param name="component_appid">第三方平台appid</param>
        /// <returns></returns>
        public static GetComponentPreAuthCodeResult GetComponentPreAuthCode(this MpHelper helper, string component_access_token, string component_appid)
        {
            string url = string.Format("{0}cgi-bin/component/api_create_preauthcode?component_access_token={1}", baseurl, component_access_token);

            return(HttpHelper.HttpPost.GetJsonResult <dynamic, GetComponentPreAuthCodeResult>(url, new { component_appid = component_appid }));
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static GetSNSAccessTokenResult GetSNSAccessToken(this MpHelper helper, string appId, string appSecret, string code)
        {
            string url = string.Format("{0}sns/oauth2/access_token?appid={1}&secret={2}&code={3}&grant_type=authorization_code", baseurl, appId, appSecret, code);

            return(HttpHelper.HttpGet.GetJsonResult <GetSNSAccessTokenResult>(url));
        }
コード例 #7
0
        /// <summary>
        /// 拉取用户信息(需scope为 snsapi_userinfo)
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="access_token"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public static GetUserInfoResult GetSNSUserInfo(this MpHelper helper, string access_token, string openId)
        {
            string url = string.Format("{0}sns/userinfo?access_token={1}&openid={2}", baseurl, access_token, openId);

            return(HttpHelper.HttpGet.GetJsonResult <GetUserInfoResult>(url));
        }
コード例 #8
0
        /// <summary>
        /// 刷新access_token(如果需要)
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="appid"></param>
        /// <param name="refresh_token"></param>
        /// <returns></returns>
        public static RefreshSNSAccessTokenResult RefreshSNSAccessToken(this MpHelper helper, string appid, string refresh_token)
        {
            string url = string.Format("{0}sns/oauth2/refresh_token?appid={1}&grant_type=refresh_token&refresh_token={2}", baseurl, appid, refresh_token);

            return(HttpHelper.HttpGet.GetJsonResult <RefreshSNSAccessTokenResult>(url));
        }