码迷,mamicode.com
首页 > 微信 > 详细

微信OAuth2网页授权

时间:2015-01-27 14:45:13      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YTO.WeiXin.Model;
using YTO.Framework.Core;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace WeiXin.Core
{
    public class OAuth20
    {
        public static string OAuth(string code)
        {
            string AppID = JobBase.GetConfParamValue(ParamEnum.AppID).ToString();
            string AppSecret = JobBase.GetConfParamValue(ParamEnum.AppSecret).ToString();
            string url = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", AppID, AppSecret, code);
            string Jsonstr = RequestHelper.SendGet(url);
            JObject obj = JObject.Parse(Jsonstr);
            string openId = obj["openid"].ToString().Replace("\"",string.Empty);
            return openId;
        }
    }
}

 

微信OAuth2网页授权

标签:

原文地址:http://www.cnblogs.com/slu182/p/4252732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!