项目地址:https://github.com/netnr/Netnr.Login

微博接入地址:http://open.weibo.com/development

接入微博登录需要做哪些事情:

  • 备案域名,公网环境,成熟站点
  • 创建应用,填写网站地址,并得到App KeyApp Secret

接入方式:OAuth2.0

开发流程:

示例

//获取 access_token
var accessToken_ResultEntity = Weibo.AccessToken(new Weibo_AccessToken_RequestEntity()
{
    code = Request.Query["code"]
});

//获取 access_token 的授权信息
var tokenInfo_ResultEntity = Weibo.GetTokenInfo(new Weibo_GetTokenInfo_RequestEntity()
{
    access_token = accessToken_ResultEntity.access_token
});

//获取 users/show
var userShow_ResultEntity = Weibo.UserShow(new Weibo_UserShow_RequestEntity()
{
    access_token = accessToken_ResultEntity.access_token,
    uid = Convert.ToInt64(tokenInfo_ResultEntity.uid)
});

//身份唯一标识
string openId = accessToken_ResultEntity.access_token;
if (string.IsNullOrWhiteSpace(openId))
{
    throw new Exception("身份验证失败");
}

留言

ˆ