Пример #1
0
        public async Task <dynamic> _Call_xiami_api(string methodName, params string[] args)
        {
            var p = new List <string>()
            {
                "api_get", methodName
            };

            if (args != null)
            {
                p.AddRange(args);
            }
            Artwork.MessageBus.MessageBus.Instance.Publish(new MsgSetBusy(this, true));
            string res = await RunProgramHelper.RunProgramGetOutput(ApiPath, p.ToArray());

            Artwork.MessageBus.MessageBus.Instance.Publish(new MsgSetBusy(this, false));
            var json = res.ToDynamicObject();

            if (!(json is string) && !(json is Array) && json.error != null)
            {
                MessageBox.Show(json.error.ToString());
                return(null);
            }

            return(json);
        }
Пример #2
0
        public async Task _Login()
        {
            Global.AppSettings["xiami_avatar"]    = "";
            Global.AppSettings["xiami_nick_name"] = "";
            var res = await RunProgramHelper.RunProgramGetOutput(ApiPath, new[] {
                "get_new_token",
                Global.AppSettings["xiami_username"],
                Global.AppSettings["xiami_password"],
            });

            var json = res.ToDynamicObject();

            if (json.error != null)
            {
                MessageBox.Show(json.error.ToString());
                return;
            }
            var r = await Call_xiami_api("Members.showUser");

            if (r.error != null)
            {
                MessageBox.Show(r.error.ToString());

                return;
            }

            Global.AppSettings["xiami_uid"]       = r.user_id.ToString();
            Global.AppSettings["xiami_nick_name"] = string.Format("来自{0}的{1}", r.city, r.nick_name);
            string avatarUrl = r.avatar.ToString();

            isLoggedIn = true;
            if (!string.IsNullOrEmpty(avatarUrl))
            {
                Global.AppSettings["xiami_avatar"] = avatarUrl;
            }
        }