public override async void OnSendAuthResponse(SendAuth.Resp response) { base.OnSendAuthResponse(response); if (response.ErrCode == 0) { if (!string.IsNullOrEmpty(response.Code)) { var token = await WeChatSns.GetAccessTokenAsync(response.Code); if (token != null) { var user = await WeChatSns.GetUserInfoAsync(token.AccessToken, token.OpenId); var dialog = new MessageDialog($"name:{user.Nickname}\r\nopenid:{user.OpenId}", "授权成功"); await dialog.ShowAsync(); } } } else { var dialog = new MessageDialog("授权失败"); await dialog.ShowAsync(); } }
public MainPage() { this.InitializeComponent(); WeChatSns.Initialize("[YOUR APP ID]", "[YOUR APP SECRET]", "[YOUR SCOPE]"); }