Ejemplo n.º 1
0
 public static void LogOff(SocialType type)
 {
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         string path = string.Format(ACCESS_TOKEN_PREFIX, type);
         if (store.FileExists(path))
         {
             store.DeleteFile(path);
         }
         if (type == SocialType.Weibo)
         {
             WeiboAccessToken = null;
         }
         else if (type == SocialType.Tencent)
         {
             TencentAccessToken = null;
         }
         else if (type == SocialType.Renren)
         {
             RenrenAccessToken = null;
         }
         else if (type == SocialType.Douban)
         {
             DoubanAccessToken = null;
         }
         else if (type == SocialType.Fanfou)
         {
             FanfouAccessToken = null;
         }
     }
 }
Ejemplo n.º 2
0
        public static ClientInfo GetClient(SocialType type)
        {
            ClientInfo client = new ClientInfo();

            switch (type)
            {
            case SocialType.Weibo:
                client.ClientId     = "2771170504";
                client.ClientSecret = "6a0c24df1abf9e6ee57c759110df414e";
                //client.RedirectUri = "http://weibo.com/";//if not set,left this property empty
                break;

            case SocialType.Tencent:
                client.ClientId     = "";
                client.ClientSecret = "";
                break;

            case SocialType.Renren:
                client.ClientId     = "";
                client.ClientSecret = "";
                break;

            default:
                break;
            }
            return(client);
        }
Ejemplo n.º 3
0
 public static void LogOff(SocialType type)
 {
     if (MessageBox.Show(LangResource.LogOffConfirm, "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
     {
         return;
     }
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         string path = string.Format(ACCESS_TOKEN_PREFIX, type);
         if (store.FileExists(path))
         {
             store.DeleteFile(path);
         }
         if (type == SocialType.Weibo)
         {
             WeiboAccessToken = null;
         }
         else if (type == SocialType.Tencent)
         {
             TencentAccessToken = null;
         }
         else if (type == SocialType.Renren)
         {
             RenrenAccessToken = null;
         }
         else if (type == SocialType.QZone)
         {
             QZoneAccessToken = null;
         }
     }
     Deployment.Current.Dispatcher.BeginInvoke(delegate
     {
         MessageBox.Show(LangResource.LogOffSuccess);
     });
 }
Ejemplo n.º 4
0
 public static ClientInfo GetClient(SocialType type)
 {
     ClientInfo client = new ClientInfo();
     switch (type)
     {
         case SocialType.Weibo:
             client.ClientId = "958678939";
             client.ClientSecret = "8436644de1b06228d7f6195a6e0e5bd7";
             client.RedirectUri = "http://tmango.com";//如果是新浪微博,需要在open.weibo.com-->我的应用-->应用信息-->高级信息 设置回调页面
             break;
         case SocialType.Tencent:
             client.ClientId = "801184653";
             client.ClientSecret = "d26955f60eb7db07a2a1f62c4743edc0";
             break;
         case SocialType.Renren:
             client.ClientId = "96733da4fd3f459199c05f9b6c95f284";
             client.ClientSecret = "8f49244064ea44c195bc9e0279080e4c";
             break;
         case SocialType.Douban:
             client.ClientId = "";
             client.ClientSecret = "";
             break;
         case SocialType.Net:
             client.ClientId = "";
             client.ClientSecret = "";
             break;
         case SocialType.Sohu:
             client.ClientId = "";
             client.ClientSecret = "";
             break;
         default:
             break;
     }
     return client;
 }
Ejemplo n.º 5
0
        public static SocialEntry Read(Int64 character, IDataReader reader, SocialType type)
        {
            if (!reader.Read())
                return null;

            SocialEntry entry;

            if (type == SocialType.Enemy)
            {
                var eentry = new EnemyEntry
                {
                    Race = reader.GetByte(1)
                };
                //eentry.TimesKilled = reader.GetByte("TimesKilled");
                //eentry.TimesKilledBy = reader.GetByte("TimesKilledBy");

                entry = eentry;
            }
            else
                entry = new SocialEntry();

            entry.Character = character;
            entry.OtherCharacter = reader.GetInt64(0);
            entry.Level = reader.GetByte(3);
            entry.LastContinentId = reader.GetUInt32(4);
            entry.Class = reader.GetByte(2);
            entry.Online = false;
            entry.Name = reader.GetString(5);
            entry.Type = (SocialType)reader.GetByte(6);

            return entry;
        }
Ejemplo n.º 6
0
 public async Task <string> SocialSignIn(string socialToken, SocialType socialType, CancellationTokenSource cancellationTokenSource)
 {
     return(await Post <string>(SIGN_IN_SOCIAL_URL, ToStringContent(new SocialAuthRequest()
     {
         Token = socialToken, Type = socialType
     }), cancellationToken : cancellationTokenSource.Token));
 }
Ejemplo n.º 7
0
        public IList<SocialEntry> GetEntries(Int64 coid, SocialType type)
        {
            var list = new List<SocialEntry>();

            try
            {
                lock (DataAccess.DatabaseAccess)
                {
                    using (var comm = DataAccess.DatabaseAccess.CreateCommand(String.Format("SELECT `s`.`Coid`, `c`.`Race`, `c`.`Class`, `c`.`Level`, `c`.`LastMapId`, `c`.`Name`, `s`.`Type` FROM `social` AS `s` LEFT JOIN `vehicle` AS `v` ON `s`.`Coid` = `v`.`OwnerCoid` LEFT JOIN `character` AS `c` ON `c`.`Coid` = `v`.`OwnerCoid` WHERE `s`.`OwnerCoid` = {0}{1}", coid, (type != SocialType.All ? String.Format(" AND `s`.`Type` = {0}", (Byte)type) : ""))))
                    {
                        using (var reader = comm.ExecuteReader())
                        {
                            while (true)
                            {
                                var s = SocialEntry.Read(coid, reader, type);
                                if (s == null)
                                    break;

                                list.Add(s);
                            }

                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("Exception in GetEntries(Int64, SocialType)! Exception: {0}", LogType.Error, e);
            }
            return list;
        }
Ejemplo n.º 8
0
        public async Task <UserDto> GetUserViaExternalSocialNet(string code, SocialType socialType, bool isTest = false)
        {
            Logger.LogInformation($"{nameof(ExternalAuthService)}.{nameof(GetUserViaExternalSocialNet)}.Start via code from web client");
            NormalizedSocialUserData socialUserData;

            switch (socialType)
            {
            //socialUserData = await _fbService.GetUserInfoAsync(code);
            //break;
            case SocialType.Vk:
                socialUserData = await VkService.GetUserInfoAsync(code, isTest);

                break;

            case SocialType.Facebook:
            case SocialType.Twiter:
            case SocialType.GooglePlus:
            case SocialType.Telegram:
            case SocialType.Badoo:
            case SocialType.Nothing:
            default: throw new Exception($"We do not support logging via {socialType}.");
            }
            var result = await ExternalUserProcessing(socialUserData, socialType);

            Logger.LogInformation($"{nameof(ExternalAuthService)}.{nameof(GetUserViaExternalSocialNet)}.End via code from web client");
            return(result);
        }
Ejemplo n.º 9
0
        public async Task <UserDto> GetUserViaExternalSocialNet(long externalUserId, string email, string externalToken,
                                                                long expiresIn, SocialType socialType)
        {
            Logger.LogInformation($"{nameof(ExternalAuthService)}.{nameof(GetUserViaExternalSocialNet)}.Start Via email from mobile");
            NormalizedSocialUserData socialUserData;

            switch (socialType)
            {
            case SocialType.Vk:
                socialUserData = await VkService.GetUserInfoAsync(externalUserId, email, externalToken, expiresIn);

                break;

            case SocialType.Facebook:
            case SocialType.Twiter:
            case SocialType.GooglePlus:
            case SocialType.Telegram:
            case SocialType.Badoo:
            case SocialType.Nothing:
            default: throw new Exception($"We do not support mobile logging via {socialType}.");
            }

            var result = await ExternalUserProcessing(socialUserData, socialType);

            Logger.LogInformation($"{nameof(ExternalAuthService)}.{nameof(GetUserViaExternalSocialNet)}.End Via email from mobile");
            return(result);
        }
Ejemplo n.º 10
0
        public async Task <string> SocialSignIn(string socialToken, SocialType socialType, CancellationTokenSource cancellationTokenSource)
        {
            await Task.Delay(1000);

            System.Diagnostics.Debug.WriteLine(IsRussianCulture ? $"Выполнен вход в социальную сеть {socialType.ToString()}; Token :<{socialToken}>" : $"You successfully authorized with {Enum.GetName(typeof(SocialType), socialType)}");
            return(TOKEN);
        }
Ejemplo n.º 11
0
        public static ClientInfo GetClient(SocialType type)
        {
            ClientInfo client = new ClientInfo();

            switch (type)
            {
            case SocialType.Weibo:
                client.ClientId     = "3078098760";
                client.ClientSecret = "c922e2b287b0119bb7efeb855f768caf";
                client.RedirectUri  = "http://yue.fm";
                break;

            case SocialType.Tencent:
                client.ClientId     = "801238433";
                client.ClientSecret = "e8106e640888edfe5c625c5604dd27ef";
                break;

            case SocialType.Renren:
                client.ClientId     = "f48fa7cc377c4bafaf66f6d84afc48e8";
                client.ClientSecret = "f1a2c691e0964a54965a1ec24795deb1";
                break;

            case SocialType.Douban:
                client.ClientId     = "06adb4bf2a683e6a14091e3d7f38bb3e";
                client.ClientSecret = "f4143a2feb70e01e";
                client.RedirectUri  = "http://yue.fm";
                break;

            default:
                break;
            }
            return(client);
        }
Ejemplo n.º 12
0
 internal void DispathAccessTokenNotFound(SocialType type)
 {
     if (onAccessTokenNotFound != null)
     {
         onAccessTokenNotFound(type);
     }
 }
        public void SetData(SocialType type, ClientInfo client)
        {
            string path = "";

            if (type == SocialType.Weibo)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/weibo.png";
            }
            else if (type == SocialType.Tencent)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/tencent.png";
            }
            else if (type == SocialType.Renren)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/renren.png";
            }
            else if (type == SocialType.QZone)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/qzone.png";
            }
            this.imgLogo.Source = new BitmapImage {
                UriSource = new Uri(path, UriKind.Relative)
            };
            SocialAPI.Client  = client;
            this.client       = client;
            currentType       = type;
            webbrowser.Source = new Uri(SocialKit.GetAuthorizeUrl(currentType, client), UriKind.Absolute);
        }
Ejemplo n.º 14
0
 void Prepare()
 {
     current       = SocialType.Twitter;
     sprite.sprite = sprites[current];
     sprite.color  = Color.clear;
     text.color    = Color.clear;
 }
Ejemplo n.º 15
0
        public async Task <IActionResult> PutSocialType([FromRoute] int id, [FromBody] SocialType socialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != socialType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(socialType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SocialTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 16
0
        public void Save()
        {
            GamervineDataContext gdc = new GamervineDataContext();

            var user = from usc in gdc.UserSocialConnections
                       join u in gdc.Users on usc.UserId equals u.UserId
                       where usc.ConnectionUserId == SocialConnId && usc.Type == SocialType.GetHashCode()
                       select u;

            if (user.Count() > 0)
            {
                User         u  = user.First();
                PropertyInfo pi = u.GetType().GetProperty(Field);
                if (pi != null)
                {
                    if (pi.PropertyType == typeof(Int16) ||
                        pi.PropertyType == typeof(Int32) ||
                        pi.PropertyType == typeof(Int64) ||
                        pi.PropertyType == typeof(Nullable <int>))
                    {
                        pi.SetValue(u, Utility.ToInt(Value), null);
                    }

                    gdc.SubmitChanges();
                }
            }
        }
Ejemplo n.º 17
0
 void onLoginComplete(SocialType arg1, bool arg2)
 {
     if (arg2)
     {
         GetAccessTokenWithSocial(SocialService.GetSocialNetwork(arg1).AccessToken);
     }
 }
Ejemplo n.º 18
0
 internal void SetOnLoginComplete(SocialType type, bool value)
 {
     if (onLoginComplete != null)
     {
         onLoginComplete(type, value);
     }
 }
Ejemplo n.º 19
0
 internal void DispathInitComplete(SocialType type)
 {
     if (onInitComplete != null)
     {
         onInitComplete(type);
     }
 }
Ejemplo n.º 20
0
        public static async ValueTask <string> PostAuthSocialGetTokenAsync(HttpClient client, WebsiteKind websiteKind,
                                                                           SocialType socialType, string token, string email, bool linking = false, double apiVersion = Core.ApiVersion)
        {
            using var response = await PostAuthSocialGetResponseAsync(client, websiteKind, socialType, token, email, linking,
                                                                      apiVersion).ConfigureAwait(false);

            return(response.Headers.FirstOrDefault(h => h.Key == "x-device-token").Value.FirstOrDefault());
        }
Ejemplo n.º 21
0
        public void RemoveSocialInvite(ulong hostId, SocialType type)
        {
            SocialInviteRequest inviteRequest = FindSocialInvite(hostId, type);

            if (inviteRequest != null)
            {
                socialInviteLookup.Remove(inviteRequest);
            }
        }
Ejemplo n.º 22
0
        public static void AddEntry(TNLConnection session, Packet packet, SocialType type)
        {
            packet.ReadPadding(4);
            var coid = packet.ReadLong();
            /*var name = */packet.ReadUtf8StringOn(17);
            packet.ReadPadding(7);

            DataAccess.Social.AddEntry(session.CurrentCharacter.GetCOID(), coid, type);
        }
Ejemplo n.º 23
0
 private static void LoginCallback(SocialType type, bool status)
 {
     SocialService.Instance.onLoginComplete -= LoginCallback;
     if (loginCallback != null)
     {
         loginCallback();
         loginCallback = null;
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Find a base social entity casted to supplied generic type.
 /// </summary>
 public static T FindSocialEntity <T>(SocialType type, uint id)
     where T : SocialBase
 {
     if (!socialEntities.TryGetValue(((uint)type << 56) | id, out SocialBase socialEntity))
     {
         return(null);
     }
     return((T)socialEntity);
 }
Ejemplo n.º 25
0
        public async Task <bool> UpdateExternalAccessToken(long externalId, SocialType socialType, string externalToken, long expiresIn)
        {
            var social = await
                         _contextAccount.SocialEntities.FirstOrDefaultAsync(x => x.SocialType == socialType && x.ExternalId == externalId);

            social.ExternalToken = externalToken;
            social.ExpiresIn     = expiresIn;
            return(await _contextAccount.SaveChangesAsync() > 0);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Decline all pending social invites of a type, if no type is specified all invites will be declined.
        /// </summary>
        public void DeclineSocialInvites(SocialType type = SocialType.None)
        {
            IEnumerable <SocialInviteRequest> invites = type != SocialType.None ? socialInviteLookup.Where(s => s.Type == type) : socialInviteLookup;

            foreach (SocialInviteRequest inviteRequest in invites)
            {
                SocialBase socialEntity = SocialManager.FindSocialEntity <SocialBase>(inviteRequest.Type, inviteRequest.EntityId);
                socialEntity?.InviteResponse(this, 0);
            }
        }
Ejemplo n.º 27
0
        // GET: Admin/SocialType/Update

        public ActionResult Update(int id)
        {
            SocialType socialType = db.SocialTypes.Find(id);

            if (socialType == null)
            {
                return(HttpNotFound());
            }
            return(View(socialType));
        }
Ejemplo n.º 28
0
        public ActionResult Update(SocialType socialType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(socialType).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(socialType));
        }
Ejemplo n.º 29
0
        public ActionResult Create(SocialType socialType)
        {
            if (ModelState.IsValid)
            {
                db.SocialTypes.Add(socialType);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(socialType));
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> PostSocialType([FromBody] SocialType socialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SocialTypes.Add(socialType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSocialType", new { id = socialType.Id }, socialType));
        }
Ejemplo n.º 31
0
 internal static string GetAuthorizeUrl(SocialType type, ClientInfo client)
 {
     string url = "";
     switch (type)
     {
         case SocialType.Weibo:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "https://api.weibo.com/oauth2/default.html";
             }
             url = "https://api.weibo.com/oauth2/authorize?client_id=" + client.ClientId + "&response_type=code&redirect_uri=" + client.RedirectUri + "&display=mobile";
             break;
         case SocialType.Tencent:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "http://t.qq.com";
             }
             url = "https://open.t.qq.com/cgi-bin/oauth2/authorize?client_id=" + client.ClientId + "&response_type=code&redirect_uri=" + client.RedirectUri + "&wap=false";
             break;
         case SocialType.Renren:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "http://graph.renren.com/oauth/login_success.html";
             }
             url = "https://graph.renren.com/oauth/authorize?response_type=code&client_id=" + client.ClientId + "&redirect_uri=" + client.RedirectUri + "&display=mobile&scope=photo_upload";
             break;
         case SocialType.QZone:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "http://open.z.qq.com/moc2/success.jsp";
             }
             url = "https://openmobile.qq.com/oauth2.0/m_authorize?response_type=token&client_id=" + client.ClientId + "&redirect_uri=" + client.RedirectUri + "&display=mobile";
             break;
         case SocialType.Twitter:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 
             }
             url = "";
             break;
         case SocialType.Facebook:
             break;
         case SocialType.Douban:
             break;
         case SocialType.Net:
             break;
         case SocialType.Sohu:
             break;
         default:
             break;
     }
     return url;
 }
Ejemplo n.º 32
0
        internal static string GetAuthorizeUrl(SocialType type, ClientInfo client)
        {
            string url = "";

            switch (type)
            {
            case SocialType.Weibo:
                if (string.IsNullOrEmpty(client.RedirectUri))
                {
                    client.RedirectUri = "https://api.weibo.com/oauth2/default.html";
                }
                url = "https://api.weibo.com/oauth2/authorize?client_id=" + client.ClientId + "&response_type=code&redirect_uri=" + client.RedirectUri + "&display=mobile";
                break;

            case SocialType.Tencent:
                if (string.IsNullOrEmpty(client.RedirectUri))
                {
                    client.RedirectUri = "http://t.qq.com";
                }
                url = "https://open.t.qq.com/cgi-bin/oauth2/authorize?client_id=" + client.ClientId + "&response_type=code&redirect_uri=" + client.RedirectUri + "&wap=false";
                break;

            case SocialType.Renren:
                if (string.IsNullOrEmpty(client.RedirectUri))
                {
                    client.RedirectUri = "http://graph.renren.com/oauth/login_success.html";
                }
                url = "https://graph.renren.com/oauth/authorize?response_type=code&client_id=" + client.ClientId + "&redirect_uri=" + client.RedirectUri + "&display=mobile&scope=photo_upload";
                break;

            case SocialType.QZone:
                if (string.IsNullOrEmpty(client.RedirectUri))
                {
                    client.RedirectUri = "http://open.z.qq.com/moc2/success.jsp";
                }
                url = "https://openmobile.qq.com/oauth2.0/m_authorize?response_type=token&client_id=" + client.ClientId + "&redirect_uri=" + client.RedirectUri + "&display=mobile";
                break;

            case SocialType.Douban:
                break;

            case SocialType.Net:
                break;

            case SocialType.Sohu:
                break;

            default:
                break;
            }
            return(url);
        }
Ejemplo n.º 33
0
 public void AddEntry(Int64 coid, Int64 friendCoid, SocialType type)
 {
     try
     {
         lock (DataAccess.DatabaseAccess)
             using (var comm = DataAccess.DatabaseAccess.CreateCommand(String.Format("INSERT INTO `social` (`OwnerCoid`, `Coid`, `Type`) VALUES ({0}, {1}, {2})", coid, friendCoid, (Byte)type)))
                 comm.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.WriteLog("Exception in AddEntry(Int64, Int64, SocialType)! Exception: {0}", LogType.Error, e);
     }
 }
Ejemplo n.º 34
0
 public void RemoveEntry(Int64 coid, Int64 friendCoid, SocialType type)
 {
     try
     {
         lock (DataAccess.DatabaseAccess)
             using (var comm = DataAccess.DatabaseAccess.CreateCommand(String.Format("DELETE FROM `social` WHERE `OwnerCoid` = {0} AND `Coid` = {1} AND `Type` = {2}", coid, friendCoid, (Byte)type)))
                 comm.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.WriteLog("Exception in RemoveEntry(Int64, Int64, SocialType)! Exception: {0}", LogType.Error, e);
     }
 }
Ejemplo n.º 35
0
        // GET: Admin/SocialType/Delete

        public ActionResult Delete(int id)
        {
            SocialType socialType = db.SocialTypes.Find(id);

            if (socialType == null)
            {
                return(HttpNotFound());
            }
            db.SocialTypes.Remove(socialType);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 36
0
        public static void AppRequest(SocialType type, string message, string[] to, string title, Action <bool, string[]> onRequestComplete)
        {
            if (Application.isEditor)
            {
                if (onRequestComplete != null)
                {
                    onRequestComplete(false, null);
                }
                return;
            }

            ProcessLogin(type, () => GetSocialNetwork(type).AppRequest(message, to, title, onRequestComplete));
        }
Ejemplo n.º 37
0
 void Rotate2(SocialType social)
 {
     sprite.sprite             = sprites[social];
     sprite.transform.rotation = Quaternion.Euler(0, -90, 0);
     iTween.RotateBy(sprite.gameObject, new Hashtable()
     {
         { "y", 0.25f },
         { "time", rotationDuration },
         { "easetype", iTween.EaseType.easeOutQuad },
         { "oncomplete", "FinishRotate" },
         { "oncompletetarget", gameObject }
     });
 }
Ejemplo n.º 38
0
 /// <summary>
 /// 导航到具体社交网站授权页
 /// </summary>
 /// <param name="socialType"></param>
 /// <param name="page"></param>
 public static void NavigateToSocial(SocialType socialType, PhoneApplicationPage page)
 {
     switch (socialType)
     {
         case SocialType.SINA:
             page.NavigationService.Navigate(SinaSocialUri); break;
         case SocialType.TENCENT:
             page.NavigationService.Navigate(TencentSocialUri); break;
         case SocialType.RENREN:
             page.NavigationService.Navigate(RenrenSocialUri); break;
         default:
             break;
     }
 }
Ejemplo n.º 39
0
 /// <summary>
 /// do share matters
 /// </summary>
 /// <param name="type"></param>
 private void DoShare(SocialType type)
 {
     App.CurrentSocialType = type;
     App.Statues = "share text only for test usage";
     bool isLogin = true;
     switch (type)
     {
         case SocialType.Weibo:
             if (!(SocialAPI.WeiboAccessToken == null || SocialAPI.WeiboAccessToken.IsExpired))
             {
                 isLogin = false; 
             }
             break;
         case SocialType.Tencent:
             if (!(SocialAPI.TencentAccessToken == null || SocialAPI.TencentAccessToken.IsExpired))
             {
                 isLogin = false;
             }
             break;
         case SocialType.Renren:
             if (!(SocialAPI.RenrenAccessToken == null || SocialAPI.RenrenAccessToken.IsExpired))
             {
                 isLogin = false;
             }
             break;
         case SocialType.Douban:
             break;
         case SocialType.Net:
             break;
         case SocialType.Sohu:
             break;
         default:
             break;
     }
     if (isLogin)
     {
         NavigationService.Navigate(new Uri("/SocialLoginPage.xaml", UriKind.Relative));
     }
     else
     {
         NavigationService.Navigate(new Uri("/SocialSendPage.xaml", UriKind.Relative));
     }
 }
Ejemplo n.º 40
0
 internal static string GetTokenUrl(SocialType type, ClientInfo client, string code)
 {
     string url = "";
     switch (type)
     {
         case SocialType.Weibo:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "https://api.weibo.com/oauth2/default.html";
             }
             url = "https://api.weibo.com/oauth2/access_token?client_id=" + client.ClientId + "&client_secret=" + client.ClientSecret + "&grant_type=authorization_code&redirect_uri=" + client.RedirectUri + "&" + code;
             break;
         case SocialType.Tencent:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "http://t.qq.com";
             }
             url = "https://open.t.qq.com/cgi-bin/oauth2/access_token?client_id=" + client.ClientId + "&client_secret=" + client.ClientSecret + "&redirect_uri=" + client.RedirectUri + "&grant_type=authorization_code&" + code;
             break;
         case SocialType.Renren:
             if (string.IsNullOrEmpty(client.RedirectUri))
             {
                 client.RedirectUri = "http://graph.renren.com/oauth/login_success.html";
             }
             url = "https://graph.renren.com/oauth/token?grant_type=authorization_code&client_id=" + client.ClientId + "&redirect_uri=" + client.RedirectUri + "&client_secret=" + client.ClientSecret + "&" + code;
             break;
         case SocialType.QZone:
             //QQ空间不需要Code换取token
             break;
         case SocialType.Douban:
             break;
         case SocialType.Net:
             break;
         case SocialType.Sohu:
             break;
         default:
             break;
     }
     return url;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// 获取客户端社交属性信息
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static ClientInfo GetClient(SocialType type)
 {
     ClientInfo client = new ClientInfo();
     switch (type)
     {
         case SocialType.Weibo:
             client.ClientId = "943422421";
             client.ClientSecret = "1562b38947e4c8e1bee082ea9c130425";
             client.RedirectUri = "https://api.weibo.com/oauth2/default.html";
             break;
         case SocialType.Tencent:
             client.ClientId = "801317241";
             client.ClientSecret = "7c00fece2e444ca7bba1a48ff635c8a0";
             break;
         case SocialType.Renren:
             client.ClientId = "227650";
             client.ClientApiKey = "67c6a7fcf1754d20991d42299378751f";
             client.ClientSecret = "6d0d97c1ba9b417fb2beadb9cd55a5bc ";
             break;
         default:
             break;
     }
     return client;
 }
Ejemplo n.º 42
0
        public void SetData(SocialType type, ClientInfo client)
        {
            string path = "";
            if (type == SocialType.Weibo)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/weibo.png";
            }
            else if (type == SocialType.Tencent)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/tencent.png";
            }
            else if (type == SocialType.Renren)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/renren.png";
            }
            else if (type == SocialType.QZone)
            {
                path = "/Alexis.WindowsPhone.Social;component/Images/qzone.png";
            }
            else if (type == SocialType.Twitter)
            {

            }
            this.imgLogo.Source = new BitmapImage { UriSource = new Uri(path, UriKind.Relative) };
            SocialAPI.Client = client;
            this.client = client;
            currentType = type;
            if (type== SocialType.Twitter)
            {
                
            }
            else
            {
                webbrowser.Source = new Uri(SocialKit.GetAuthorizeUrl(currentType, client), UriKind.Absolute);
            }            
        }
Ejemplo n.º 43
0
        private async Task<SocialInfo> VerifyExternalAccessToken(SocialType type, string accessToken)
        {
            var userInfo = new SocialInfo() { IsSuccess = false };
            var verifyTokenEndPoint = "";

            switch (type)
            {
                case SocialType.Facebook:
                    {
                        //You can get it from here: https://developers.facebook.com/tools/accesstoken/
                        //More about debug_tokn here: http://stackoverflow.com/questions/16641083/how-does-one-get-the-app-access-token-for-debug-token-inspection-on-facebook
                        var appToken = "FacebookAppToken".AppSetting();
                        verifyTokenEndPoint = string.Format("https://graph.facebook.com/debug_token?input_token={0}&access_token={1}", accessToken, appToken);
                    }
                    break;
                case SocialType.Google:
                    verifyTokenEndPoint = string.Format("https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={0}", accessToken);
                    break;
            }
            try
            {

                dynamic jObj = await Common.GetRequestResponse(verifyTokenEndPoint);
                if (jObj == null) return userInfo;

                var user_id = "";
                var app_id = "";

                switch (type)
                {
                    case SocialType.Facebook:
                        user_id = jObj["data"]["user_id"];
                        app_id = jObj["data"]["app_id"];
                        if (string.Equals("FacebookAppId".AppSetting(), app_id, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(user_id))
                        {
                            // https://graph.facebook.com/me?fields=id,name,email,picture&accesstoken=
                            // get info                            
                            userInfo.UserId = user_id;
                            userInfo.IsSuccess = true;
                        }
                        break;
                    case SocialType.Google:
                        {
                            //https://developers.google.com/identity/sign-in/web/sign-in
                            user_id = jObj["user_id"];
                            app_id = jObj["audience"];
                            var googleClientId = "GoogleClientId".AppSetting();

                            if (string.Equals(googleClientId, app_id, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(user_id))
                            {
                                userInfo.UserId = user_id;
                                userInfo.IsSuccess = true;
                                userInfo.Email = jObj["email"];
                            }
                        }
                        break;
                }


            }
            catch (Exception)
            {

            }
            return userInfo;
        }
Ejemplo n.º 44
0
 /// <summary>
 /// Идентификация пользователя через внешние идентифицирующие сервисы
 /// </summary>
 public static bool TrySignIn(string key, SocialType socialtype, bool createPersistentCookie, string ip)
 {
     return _accountService.TrySignIn(key, socialtype, createPersistentCookie, ip);
 }
Ejemplo n.º 45
0
 public static bool ConnectSocialAccount(User user, SocialType socialType, string link, string key)
 {
     return _accountService.ConnectSocialAccount(user, socialType,link, key);
 }
Ejemplo n.º 46
0
 public static void DisconnectSocialAccount(User user, SocialType socialType)
 {
     _accountService.DisconnectSocialAccount(user, socialType);
 }
Ejemplo n.º 47
0
 public SocialEventArgs(SocialType socialType, SocialBase socialData)
 {
     SocialType = socialType;
     SocialData = socialData;
 }
Ejemplo n.º 48
0
        public static void UploadStatusWithPic(SocialType type, string status, string imgPath, Action<bool, Exception> action)
        {
            HttpUploader uploader = new HttpUploader();
            uploader.parameters = new Dictionary<string, object>();
            switch (type)
            {
                case SocialType.Weibo:
                    {
                        uploader.url = "https://api.weibo.com/2/statuses/upload.json";
                        uploader.parameters.Add("status", status);
                        uploader.parameters.Add("access_token", WeiboAccessToken.Token);
                    }
                    break;
                case SocialType.Tencent:
                    {
                        uploader.url = "https://open.t.qq.com/api/t/add_pic";
                        uploader.parameters.Add("oauth_consumer_key", Client.ClientId);
                        uploader.parameters.Add("access_token", TencentAccessToken.Token);
                        uploader.parameters.Add("openid", TencentAccessToken.OpenId);
                        uploader.parameters.Add("oauth_version", "2.a");
                        uploader.parameters.Add("scope", "all");
                        uploader.parameters.Add("format", "json");
                        uploader.parameters.Add("content", status);
                    }
                    break;
                case SocialType.Renren:
                    {
                        uploader.url = "http://api.renren.com/restserver.do";
                        uploader.parameters.Add("method", "photos.upload");
                        uploader.parameters.Add("v", "1.0");
                        uploader.parameters.Add("access_token", RenrenAccessToken.Token);
                        uploader.parameters.Add("format", "JSON");
                        uploader.parameters.Add("caption", status);
                        uploader.parameters.Add("aid", "0");

                        List<APIParameter> para = new List<APIParameter>();
                        para.Add(new APIParameter("access_token", RenrenAccessToken.Token));
                        para.Add(new APIParameter("method", "photos.upload"));
                        para.Add(new APIParameter("v", "1.0"));
                        para.Add(new APIParameter("format", "JSON"));
                        para.Add(new APIParameter("caption", status));
                        para.Add(new APIParameter("aid", "0"));
                        uploader.parameters.Add("sig", CalSig(para));
                    }
                    break;
                case SocialType.QZone:
                    {
                        uploader.url = "https://graph.qq.com/share/add_share";
                        uploader.parameters.Add("title", status);
                        uploader.parameters.Add("title", "");
                        uploader.parameters.Add("title", "");
                        uploader.parameters.Add("title", "");
                    }
                    break;
                case SocialType.Douban:
                    break;
                case SocialType.Net:
                    break;
                case SocialType.Sohu:
                    break;
                default:
                    break;
            }

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (store.FileExists(imgPath))
                {
                    using (var stream = store.OpenFile(imgPath, FileMode.Open, FileAccess.Read))
                    {
                        byte[] bytes = new byte[stream.Length];
                        stream.Read(bytes, 0, bytes.Length);
                        if (type == SocialType.Renren)
                        {
                            uploader.parameters.Add("upload", bytes);
                        }
                        else
                        {
                            uploader.parameters.Add("pic", bytes);
                        }
                    }
                }
                else
                {
                    //image do not exists
                    //TODO
                }
            }
            uploader.Submit();
            uploader.UploadCompleted += (e1, e2) =>
            {
                if (e1 is string && e1.ToString() == "ok")
                {
                    action(true, null);
                }
                else
                {
                    action(false, e1 as Exception);
                }
            };
        }
Ejemplo n.º 49
0
        /// <summary>
        /// 发送不带图片的微博
        /// 史坤
        /// 2012.7.4
        /// </summary>
        /// <param name="type"></param>
        /// <param name="status"></param>
        /// <param name="action"></param>
        public static void UpdateStatus(SocialType type, string status, Action<bool, Exception> action)
        {
            HttpUpdate uploader = new HttpUpdate();
            uploader.Type = type;
            uploader.parameters = new Dictionary<string, object>();
            switch (type)
            {
                case SocialType.Weibo:
                    {
                        uploader.url = "https://api.weibo.com/2/statuses/update.json";
                        uploader.parameters.Add("status", status);
                        uploader.parameters.Add("access_token", WeiboAccessToken.Token);
                    }
                    break;
                case SocialType.Tencent:
                    {
                        uploader.url = "https://open.t.qq.com/api/t/add";
                        uploader.parameters.Add("oauth_consumer_key", Client.ClientId);
                        uploader.parameters.Add("access_token", TencentAccessToken.Token);
                        uploader.parameters.Add("openid", TencentAccessToken.OpenId);
                        uploader.parameters.Add("oauth_version", "2.a");
                        uploader.parameters.Add("scope", "all");
                        uploader.parameters.Add("format", "json");
                        uploader.parameters.Add("content", status);
                    }
                    break;
                case SocialType.Renren:
                    {
                        uploader.url = "http://api.renren.com/restserver.do";
                        uploader.parameters.Add("method", "feed.publishFeed");
                        uploader.parameters.Add("v", "1.0");
                        uploader.parameters.Add("access_token", RenrenAccessToken.Token);
                        uploader.parameters.Add("format", "JSON");
                        uploader.parameters.Add("name", " ");
                        uploader.parameters.Add("message", status);
                        uploader.parameters.Add("description", " ");
                        uploader.parameters.Add("url", " ");

                        List<APIParameter> para = new List<APIParameter>();
                        para.Add(new APIParameter("access_token", RenrenAccessToken.Token));
                        para.Add(new APIParameter("method", "feed.publishFeed"));
                        para.Add(new APIParameter("v", "1.0"));
                        para.Add(new APIParameter("name", " "));
                        para.Add(new APIParameter("description", " "));
                        para.Add(new APIParameter("message", status));
                        para.Add(new APIParameter("url", " "));
                        para.Add(new APIParameter("format", "JSON"));

                        uploader.parameters.Add("sig", CalSig(para));
                    }
                    break;
                case SocialType.QZone:
                    {
                        uploader.url = "https://graph.qq.com/share/add_share";
                        uploader.parameters.Add("title", status);
                        uploader.parameters.Add("site", status);
                        uploader.parameters.Add("fromurl", status);
                    }
                    break;
                case SocialType.Douban:
                    break;
                case SocialType.Net:
                    break;
                case SocialType.Sohu:
                    break;
                default:
                    break;
            }
            uploader.Submit();

            uploader.UploadCompleted += (e1, e2) =>
            {
                if (e1 is string && e1.ToString() == "ok")
                {
                    action(true, null);
                }
                else
                {
                    action(false, e1 as Exception);
                }
            };
        }
Ejemplo n.º 50
0
 public static void LogOff(SocialType type)
 {
     if (MessageBox.Show(LangResource.LogOffConfirm, "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
     {
         return;
     }
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         string path = string.Format(ACCESS_TOKEN_PREFIX, type);
         if (store.FileExists(path))
         {
             store.DeleteFile(path);
         }
         if (type == SocialType.Weibo)
         {
             WeiboAccessToken = null;
         }
         else if (type == SocialType.Tencent)
         {
             TencentAccessToken = null;
         }
         else if (type == SocialType.Renren)
         {
             RenrenAccessToken = null;
         }
         else if (type == SocialType.QZone)
         {
             QZoneAccessToken = null;
         }
     }
     Deployment.Current.Dispatcher.BeginInvoke(delegate
     {
         MessageBox.Show(LangResource.LogOffSuccess);
     });
 }
 /// <summary>
 /// 进行社交分享
 /// </summary>
 /// <param name="type"></param>
 private void DoSnsShare(SocialType type)
 {
     DDSocialShareViewModel.Instance.CurrentSocialType = type;
     bool isLogin = true;
     switch (type)
     {
         case SocialType.Weibo:
             if (!(SocialAPI.WeiboAccessToken == null || SocialAPI.WeiboAccessToken.IsExpired))
             {
                 isLogin = false;
             }
             break;
         case SocialType.Tencent:
             if (!(SocialAPI.TencentAccessToken == null || SocialAPI.TencentAccessToken.IsExpired))
             {
                 isLogin = false;
             }
             break;
         case SocialType.Renren:
             if (!(SocialAPI.RenrenAccessToken == null || SocialAPI.RenrenAccessToken.IsExpired))
             {
                 isLogin = false;
             }
             break;
     }
     if (isLogin)
     {
         NavigationService.Navigate(new Uri("/Views/SocialLoginPage.xaml", UriKind.Relative));
     }
     else
     {
         NavigationService.Navigate(new Uri("/Views/SocialSendPage.xaml", UriKind.Relative));
     }
 }
Ejemplo n.º 52
0
 public static void RemoveEntry(TNLConnection session, Int64 coid, SocialType type)
 {
     DataAccess.Social.RemoveEntry(session.CurrentCharacter.GetCOID(), coid, type);
 }
Ejemplo n.º 53
0
        public ActionResult SignUp(bool? isdialog, SocialType social = SocialType.None, string returnUrl = null)
        {
            var model = new AccountSignUpViewModel
            {
                SocialType = social,
                ConnectSocial = true,
                ReturnUrl = returnUrl
            };

            if (isdialog.HasValue)
                if (isdialog.Value)
                    return View("SignUp", "_LightLayout", model);

            return View(model);
        }
Ejemplo n.º 54
0
        public ActionResult SocialDeattach(SocialType social)
        {
            if (Request.IsAuthenticated && UserContext.Current != null)
            {
                var user = DataService.PerThread.BaseUserSet.OfType<User>().SingleOrDefault(x => x.Id == UserContext.Current.Id);
                if (user == null)
                    throw new BusinessLogicException("Данный пользователь не найден");

                AccountService.DisconnectSocialAccount(user, social);
                return RedirectToAction("profile", "user", null);
            }

            throw new AuthenticationException();
        }
Ejemplo n.º 55
0
        internal static void GetToken(SocialType type, ClientInfo client, string code, Action<AccessToken> action)
        {
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(GetTokenUrl(type, client, code));
            httpWebRequest.Method = "POST";

            httpWebRequest.BeginGetResponse((p) =>
            {
                HttpWebRequest request = (HttpWebRequest)p.AsyncState;
                HttpWebResponse httpWebResponse;
                try
                {
                    httpWebResponse = (HttpWebResponse)request.EndGetResponse(p);
                }
                catch (WebException ex)
                {
                    return;
                }
                if (httpWebResponse != null)
                {
                    using (var stream = httpWebResponse.GetResponseStream())
                    {
                        AccessToken token = new AccessToken();
                        if (type == SocialType.Tencent)
                        {
                            using (var reader = new System.IO.StreamReader(stream))
                            {
                                string text = reader.ReadToEnd();
                                if (!string.IsNullOrEmpty(text))
                                {
                                    //access_token=ec70e646177f025591e4282946c19b67&expires_in=604800&name=xshf12345
                                    var acc = text.Split('&');
                                    foreach (var item in acc)
                                    {
                                        var single = item.Split('=');
                                        if (single[0] == "access_token")
                                        {
                                            token.Token = single[1];
                                        }
                                        else if (single[0] == "expires_in")
                                        {
                                            token.ExpiresTime = DateTime.Now.AddSeconds(Convert.ToInt32(single[1]));
                                        }
                                        else if (single[0] == "name")
                                        {
                                            token.UserInfo = single[1];
                                        }
                                    }
                                    token.OpenId = client.Tag;
                                }
                            }
                        }
                        else if (type == SocialType.Weibo)
                        {
                            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Weibo.WeiboAccessToken));
                            var item = ser.ReadObject(stream) as Weibo.WeiboAccessToken;
                            item.ExpiresTime = DateTime.Now.AddSeconds(Convert.ToDouble(item.expires_in));
                            token.Token = item.access_token;
                            token.ExpiresTime = item.ExpiresTime;
                            token.UserInfo = item.uid;
                        }
                        else if (type == SocialType.Renren)
                        {
                            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Renren.RenrenAccessToken));
                            var item = ser.ReadObject(stream) as Renren.RenrenAccessToken;
                            item.ExpiresTime = DateTime.Now.AddSeconds(Convert.ToDouble(item.expires_in));
                            token.Token = item.access_token;
                            token.ExpiresTime = item.ExpiresTime;
                            token.UserInfo = item.user.name;
                        }
                        string filePath = string.Format(SocialAPI.ACCESS_TOKEN_PREFIX, type.ToString());
                        JsonHelper.SerializeData<AccessToken>(filePath, token);
                        action(token);                        
                    }
                }
            }, httpWebRequest);
        }
Ejemplo n.º 56
0
	void onLoginComplete (SocialType arg1, bool arg2)
	{
		if(arg2){
			GetAccessTokenWithSocial(SocialService.GetSocialNetwork(arg1).AccessToken);
        }
	}