private async Task <string> APIForFetchLifeStreamAsync(string uid) { return(await DoubanWebProcess.GetMDoubanResponseAsync( path : string.Format(APIFormat, uid, "1970-1", next_filter, "10"), host : "m.douban.com", reffer : string.Format("https://m.douban.com/people/{0}/", uid))); }
public static async Task SetUserStatusAsync(string uid) { try { var result = await DoubanWebProcess.GetAPIResponseAsync( path : "https://m.douban.com/rexxar/api/v2/user/" + uid, host : "m.douban.com", reffer : "https://m.douban.com/mine/"); LoginStatus = GlobalHelpers.GetLoginStatus(result); Current.LoginUserBlock.Text = LoginStatus.UserName; Current.LoginUserText.SetVisibility(false); var succeed = Uri.TryCreate(LoginStatus.APIUserinfos.LargeAvatar, UriKind.Absolute, out var img_uri); if (!succeed) { succeed = Uri.TryCreate(LoginStatus.APIUserinfos.Avatar, UriKind.Absolute, out img_uri); } if (succeed) { Current.LoginUserIcon.Fill = new ImageBrush { ImageSource = new BitmapImage(img_uri) } } ; IsLogined = true; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message + "\n" + e.StackTrace); SettingsHelper.SaveSettingsValue(SettingsSelect.UserID, "LOGOUT"); IsLogined = false; } }
/// <summary> /// Fetch the interests list by movie-id and show them. Regex the uri to get the movie-id. /// </summary> /// <param name="uri">this path url</param> /// <returns>succeed or not</returns> private async Task <bool> SetInterestsAsync(Uri uri) { if (movie_id_received != null) { movie_id = movie_id_received; } else { movie_id = new Regex(@"subject/(?<movie_id>.+)").Match(uri.ToString()).Groups["movie_id"].Value; if (movie_id == "") { return(false); } } var interests_json = await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}m.douban.com/rexxar/api/v2/movie/{movie_id}/interests?count={7}&order_by=hot&start={0}&for_mobile=1", host : "m.douban.com", reffer : $"{"https://"}m.douban.com/movie/subject/{movie_id}/?refer=home"); try { var collection = JsonHelper.FromJson <MovieContentInterestsCollection>(interests_json); model.CommentsList = collection.Interests; return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Build native movie content page wrong : interests wrong."); System.Diagnostics.Debug.WriteLine(e.Message); return(false); } }
private async Task <ItemGroup <BookItem> > FetchMessageFromAPIAsync( string formatAPI, string headString, string loc_id = "108288", uint start = 0, uint count = 8, int offset = 0) { var gmodel = default(ItemGroup <BookItem>); try { var minised = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; Debug.WriteLine(string.Format(formatAPI, new object[] { headString, start, count, loc_id, minised })); var result = await DoubanWebProcess.GetMDoubanResponseAsync(string.Format(formatAPI, new object[] { headString, start, count, loc_id, minised }), "m.douban.com", "https://m.douban.com/book/"); if (result == null) { ReportWhenGoesWrong("WebActionError"); return(gmodel); } JObject jo = JObject.Parse(result); gmodel = DataProcess.SetGroupResources(jo, gmodel); gmodel = SetSingletonResources(jo, gmodel); } catch { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); } IncrementalLoadingBorder.SetVisibility(false); return(gmodel); }
private async void SetWebViewSourceAsync(Uri uri) { try { var result = htmlReturn = await DoubanWebProcess.GetMDoubanResponseAsync( path : uri.ToString(), host : "m.douban.com", reffer : "https://m.douban.com/"); var doc = new HtmlDocument(); doc.LoadHtml(result); var shouldNative = IfCanGetContent(doc.DocumentNode); if (shouldNative) { WebView.NavigateToString(GetContent(doc.DocumentNode)); SetTitleAndDescForShare(doc); } else { WebView.Source = uri; isNative = false; } } catch { WebView.Source = uri; } }
/// <summary> /// Update XAML views by url content. /// </summary> /// <param name="uri">this path url</param> private async void SetWebViewSourceAsync(Uri uri) { try { var result = htmlReturn = await DoubanWebProcess.GetMDoubanResponseAsync( path : uri.ToString(), host : "m.douban.com", reffer : "https://m.douban.com/"); var doc = new HtmlDocument(); doc.LoadHtml(result); var root = doc.DocumentNode; if (model == null) { return; } var model_state_succeed = SetDefaultModelState(root); var description_succeed = SetDescription(root.GetSectionNodeContentByClass("subject-intro")); var imagelist_succeed = SetImageList(root.GetSectionNodeContentByClass("subject-pics")); var question_succeed = SetQuestionList(root.GetSectionNodeContentByClass("subject-question")); var rec_succeed = SetRecommandsList(root.GetSectionNodeContentByClass("subject-rec")); var reviews_succeed = SetReviewsList(root.GetSectionNodeContentByClass("subject-reviews")); var interests_succeed = await SetInterestsAsync(uri); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Build native movie content page wrong : global wrong."); System.Diagnostics.Debug.WriteLine(e.Message); } finally { IncrementalLoadingBorder.SetVisibility(false); } }
private async Task <IList <DiaryItem> > FetchMessageFromAPIAsync(string target, int offset) { IList <DiaryItem> list = new List <DiaryItem>(); try { var result = await DoubanWebProcess.GetMDoubanResponseAsync(target); if (result == null) { ReportHelper.ReportAttentionAsync(GetUIString("WebActionError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } JObject jo = JObject.Parse(result); var notes = jo["notes"]; if (notes == null) { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } if (notes.HasValues) { notes.Children().ToList().ForEach(noteItem => WorkOnEachNote(noteItem, list)); } } catch { ReportHelper.ReportAttentionAsync(GetUIString("UnknownError")); } IncrementalLoadingBorder.SetVisibility(false); needContinue = list.Count != 0 ? list.Count == fetchCount : false; if (!needContinue) { ReportHelper.ReportAttentionAsync(GetUIString("SHOULD_STOP")); } startCount += (offset + 1) * fetchCount; return(list); }
public static async Task <IList <MHzSongBase> > FetchMHzSongsAsync(int list_id, string api_key, string bearer) { var result = await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/playlist?channel={list_id}&formats=null&from=&type=n&version=644&start=0&app_name=radio_android&limit=10&apikey={api_key}", host : "api.douban.com", reffer : null, bearer : bearer, userAgt : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C"); try { var jo = JObject.Parse(result); var songs = jo["song"]; var group = CreateDefaultListGroup(jo); if (songs != null && songs.HasValues) { songs.Children().ToList().ForEach(jo_song => { try { var song = CreateDefaultSongInstance(jo_song); AddSingerEachOne(song, jo_song["singers"]); AddRelease(song, jo_song["release"]); group.Songs.Add(song); } catch { /* Ingore */ } }); } return(group.Songs); } catch { return(null); } }
public async void SetFlipResourcesAsync() { try { var result = await DoubanWebProcess.GetMDoubanResponseAsync( path : "https://m.douban.com/rexxar/api/v2/promos?page=selection", host : "m.douban.com", reffer : null); JObject jo = JObject.Parse(result); var promos = jo["promos"]; if (promos.HasValues) { var newList = new List <PromosItem>(); promos.Children().ToList().ForEach(singleton => { var notif = singleton["notification"]; var uri = UriDecoder.GetUrlFromUri(singleton["uri"].Value <string>()); newList.Add(new PromosItem { ImageSrc = new Uri(singleton["image"].Value <string>()), Image = singleton["image"].Value <string>(), NotificationCount = notif.HasValues ? notif["count"].Value <uint>() : 0, NotificationVersion = notif.HasValues ? notif["version"].Value <string>() : null, Text = singleton["text"].Value <string>(), Uri = uri, ID = singleton["id"].Value <string>(), }); }); FlipResouces.Source = newList; InitFlipTimer(newList); } } catch { /* Ignore */ } }
private async void LogoutButton_ClickAsync(object sender, RoutedEventArgs e) { var path = "https://www.douban.com/accounts/logout?source=main"; await DoubanWebProcess.GetDoubanResponseAsync(path); SettingsHelper.SaveSettingsValue(SettingsSelect.UserID, "LOGOUT"); GlobalHelpers.ResetLoginStatus(); PageSlideOutStart(VisibleWidth > FormatNumber ? false : true); }
/// <summary> /// if need, run this method for auto-login. /// </summary> /// <returns></returns> private async void ClickSubmitButtonIfAutoAsync() { Submit.IsEnabled = false; SubitRing.IsActive = true; var user = EmailBox.Text; var pass = PasswordBox.Password; PasswordAndUserEncryption(user, pass); // set the abort button with keybord-focus, so that the vitual keyboad in the mobile device with disappear. Abort.Focus(FocusState.Keyboard); var result = await DoubanWebProcess.PostDoubanResponseAsync( path : "https://frodo.douban.com/service/auth2/token", host : "frodo.douban.com", reffer : null, content : new HttpFormUrlEncodedContent(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("client_id", "0dad551ec0f84ed02907ff5c42e8ec70"), new KeyValuePair <string, string>("client_secret", "9e8bb54dc3288cdf"), new KeyValuePair <string, string>("redirect_uri", "frodo://app/oauth/callback/"), new KeyValuePair <string, string>("grant_type", "password"), new KeyValuePair <string, string>("username", user), new KeyValuePair <string, string>("password", pass), //new KeyValuePair<string, string>("apiKey","0dad551ec0f84ed02907ff5c42e8ec70"), new KeyValuePair <string, string>("os_rom", "android"), }), isMobileDevice : true); var tokenReturn = default(APITokenReturn); try { JObject jo = JObject.Parse(result); tokenReturn = new APITokenReturn { AccessToken = jo["access_token"].Value <string>(), RefreshToken = jo["refresh_token"].Value <string>(), ExpiresIn = jo["expires_in"].Value <string>(), UserId = jo["douban_user_id"].Value <string>(), UserName = jo["douban_user_name"].Value <string>(), }; MainLoginPopup.IsOpen = false; try { await MainPage.SetUserStatusAsync(tokenReturn.UserId); //await MainPage.SetUserStatusAsync("155845973"); NavigateToBase?.Invoke( null, null, GetFrameInstance(FrameType.UserInfos), GetPageType(NavigateType.UserInfo)); } catch { /* Ignore. */ } } catch { ReportHelper.ReportAttentionAsync(GetUIString("LoginFailed")); } }
private async void SetWebViewSourceAsync(Uri uri) { try { var result = await DoubanWebProcess.GetMDoubanResponseAsync(uri.ToString()); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(result); var root = doc.DocumentNode; ConnectString(RemoveString(doc)); } catch { WebView.Source = uri; } }
private async void Method02Async() { var result = await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/songlist/selections?version=644&start=0&app_name=radio_android&limit=10&apikey={APIKey}", host : "api.douban.com", reffer : null, bearer : bearer, userAgt : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C"); var list = GroupsInit(result); ListResources.Source = list; }
private static async Task <string> GetRedHeartBasicAsync() { try { return(await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/redheart/basic?version=644&app_name=radio_android&apikey={APIKey}", host : "api.douban.com", reffer : null, bearer : AccessToken, userAgt : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C")); } catch { System.Diagnostics.Debug.WriteLine("fetch red-heart basic error."); return(null); } }
private async Task <IList <IndexItem> > FetchMessageFromAPIAsync(string target, int offset = 0) { IList <IndexItem> list = new List <IndexItem>(); try { var result = await DoubanWebProcess.GetMDoubanResponseAsync( path : target, host : "m.douban.com", reffer : "https://m.douban.com/"); if (result == null) { ReportHelper.ReportAttentionAsync(GetUIString("WebActionError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } JObject jo = JObject.Parse(result); var feeds = jo["recommend_feeds"]; if (feeds == null || !feeds.HasValues) { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } if (feeds.HasValues) { list.Add(new IndexItem { Type = IndexItem.ItemType.DateBlock, ThisDate = DateTime.Now.AddDays(-offset).ToString("yyyy-MM-dd"), }); feeds.Children().ToList().ForEach(singleton => { try { var targets = singleton["target"]; if (targets != null) { var type = targets["cover_url"].Value <string>() == "" ? IndexItem.ItemType.Paragraph : targets["photos_count"].Value <uint>() == 0 ? IndexItem.ItemType.Normal : IndexItem.ItemType.Gallary; var one = JsonHelper.FromJson <IndexItem>(singleton.ToString()); one.Type = type; list.Add(one); } } catch { /* Ignore, item error. */ } }); } } catch { ReportHelper.ReportAttentionAsync(GetUIString("UnknownError")); } IncrementalLoadingBorder.SetVisibility(false); return(list); }
private async void InitWhenNavigatedAsync() { var MusicChineseResult = await SetGridViewResourcesAsync("music_chinese"); MusicChineseResources.Source = MusicChineseResult?.Items; var MusicOccidentResult = await SetGridViewResourcesAsync("music_occident"); MusicOccidentResources.Source = MusicOccidentResult?.Items; var MusicJAndKResult = await SetGridViewResourcesAsync("music_japan_korea"); MusicJAndKResources.Source = MusicJAndKResult?.Items; var webResult = await DoubanWebProcess.GetMDoubanResponseAsync("https://m.douban.com/music/"); SetWrapPanelResources(webResult); SetFilterResources(webResult); StopLoadingAnimation(); }
private async void InitWhenNavigatedAsync() { var BookFictionResult = await SetGridViewResourcesAsync("book_fiction"); BookFictionResources.Source = BookFictionResult?.Items; var BookNonfictionResult = await SetGridViewResourcesAsync("book_nonfiction"); BookNonfictionResources.Source = BookNonfictionResult?.Items; var MPBookResult = await SetGridViewResourcesAsync("market_product_book"); MPBookResources.Source = MPBookResult?.Items; var webResult = await DoubanWebProcess.GetMDoubanResponseAsync("https://m.douban.com/book/"); SetWrapPanelResources(webResult); SetFilterResources(webResult); StopLoadingAnimation(); }
private async void InitWhenNavigatedAsync() { var TVDomesticResult = await SetGridViewResourcesAsync("tv_domestic"); TVDomesticResources.Source = TVDomesticResult != null ? TVDomesticResult.Items : null; var TVVarietyShowResult = await SetGridViewResourcesAsync("tv_variety_show"); TVVarietyShowResources.Source = TVVarietyShowResult != null ? TVVarietyShowResult.Items : null; var TVAmericanResult = await SetGridViewResourcesAsync("tv_american"); TVAmericanResources.Source = TVAmericanResult != null ? TVAmericanResult.Items : null; var webResult = await DoubanWebProcess.GetMDoubanResponseAsync("https://m.douban.com/tv/"); SetWrapPanelResources(webResult); SetFilterResources(webResult); StopLoadingAnimation(); }
private async void InitWhenNavigatedAsync() { var InThearerResult = await SetGridViewResourcesAsync("movie_showing"); InTheaterResources.Source = InThearerResult != null ? InThearerResult.Items : null; var WatchOnlineResult = await SetGridViewResourcesAsync("movie_free_stream"); WatchOnlineResources.Source = WatchOnlineResult != null ? WatchOnlineResult.Items : null; var LatestResult = await SetGridViewResourcesAsync("movie_latest"); LatestResources.Source = LatestResult != null ? LatestResult.Items : null; var webResult = await DoubanWebProcess.GetMDoubanResponseAsync("https://m.douban.com/movie/"); SetWrapPanelResources(webResult); SetFilterResources(webResult); StopLoadingAnimation(); }
private async Task TryLoginAsync(bool isInit = false) { try { if (isInit) { var userId = SettingsHelper.ReadSettingsValue(SettingsSelect.UserID) as string; if (userId == null || userId == "LOGOUT") { return; } LoginResult = await DoubanWebProcess.GetDoubanResponseAsync("https://douban.com/mine/", false); if (LoginResult == null) { ReportHelper.ReportAttentionAsync(GetUIString("WebActionError")); return; } var doc = new HtmlDocument(); doc.LoadHtml(LoginResult); if (doc.DocumentNode.SelectSingleNode("//div[@class='top-nav-info']") == null) { SettingsHelper.SaveSettingsValue(SettingsSelect.UserID, "LOGOUT"); return; } try { if (!IsLogined) { await MainPage.SetUserStatusAsync(userId); } SetUserStatus(); } catch { /* Ignore. */ } } else { if (!IsLogined) { NavigateToBase?.Invoke(null, null, GetFrameInstance(FrameType.Login), GetPageType(NavigateType.Login)); MainPage.OpenLoginPopup(); } else { NavigateToBase?.Invoke(null, null, GetFrameInstance(FrameType.UserInfos), GetPageType(NavigateType.UserInfo)); } } } catch { ReportHelper.ReportAttentionAsync(GetUIString("WebActionError")); } }
private async Task <IList <StatusItem> > FetchMessageFromAPIAsync(string target) { IList <StatusItem> list = new List <StatusItem>(); try { var result = await DoubanWebProcess.GetMDoubanResponseAsync(target); if (result == null) { ReportHelper.ReportAttentionAsync(GetUIString("WebActionError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } JObject jo = JObject.Parse(result); var feeds = jo["items"]; if (feeds == null) { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); IncrementalLoadingBorder.SetVisibility(false); return(list); } if (feeds.HasValues) { feeds.Children().ToList().ForEach(singleton => { try { var status = singleton["status"]; if (!status.HasValues) { return; } var item = JsonHelper.FromJson <StatusItem>(status.ToString()); item.Type = InfosItemBase.JsonType.Status; list.Add(item); } catch (Exception e) { Debug.WriteLine(e.StackTrace + Environment.NewLine + "\n Error_json content:\n" + Environment.NewLine); } }); } } catch { ReportHelper.ReportAttentionAsync(GetUIString("UnknownError")); } IncrementalLoadingBorder.SetVisibility(false); max_id = list.Count != 0 ? (list[list.Count - 1].ID - 1).ToString() : "SHOULD_STOP"; if (list.Count == 0) { ReportHelper.ReportAttentionAsync(GetUIString("SHOULD_STOP")); } return(list); }
private async void SetLikeBtnAsync(string callBack) { var likebtnMatch = new Regex(@"like-note-link:.+").Match(callBack); if (likebtnMatch.Value == "") { return; } var formatStr = "https://m.douban.com" + likebtnMatch.Value.Substring(15); Uri.TryCreate(formatStr, UriKind.Absolute, out var uri); if (uri != null) { try { var result = await DoubanWebProcess.GetMDoubanResponseAsync(uri.ToString()); var jo = JObject.Parse(result); var data = jo["data"]; if (data != null && data.HasValues) { var isliked = data["is_liked"].Value <bool>(); var number = data["n_likers"].Value <int>(); var className = isliked ? "like-btn active" : "like-btn"; var addStr = isliked ? "unlike" : "like"; var js = $@" var likebtn = document.getElementById('yeslike-btn'); if(likebtn!=null){"{"} likebtn.className = '{className}'; likebtn.innerText = {number}; likebtn.setAttribute('onclick','send_path_url(""like-note-link:'+ likebtn.getAttribute('data-url') +'/{addStr}"")'); {"}"} var dislikebtn = document.getElementById('dislike-btn'); if(dislikebtn!=null){"{"} dislikebtn.className = '{className}'; dislikebtn.innerText = {number}; dislikebtn.setAttribute('onclick','send_path_url(""like-note-link:'+ likebtn.getAttribute('data-url') +'/{addStr}"")'); {"}"} "; await WebView.InvokeScriptAsync("eval", new[] { js }); ChangeLikedBtnStateByBoolen(isliked); } } catch { /* Ignore */ } } }
private static async Task <string> GetSongDetailsAsync(string sids) { try { return(await DoubanWebProcess.PostDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/redheart/songs?version=644&app_name=radio_android&apikey={APIKey}", host : "api.douban.com", reffer : null, userAgent : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C", bearer : AccessToken, content : new HttpFormUrlEncodedContent(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("sids", sids), new KeyValuePair <string, string>("kbps", "192"), }))); } catch { System.Diagnostics.Debug.WriteLine("fetch red-heart detials error."); return(null); } }
private async Task GetMusicDetailsAsync() { try { var result = await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/song/{sid + "g" + ssid}/?version=644&start=0&app_name=radio_android&apikey={APIKey}", host : "api.douban.com", reffer : null, bearer : AccessToken, userAgt : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C"); var jo = JObject.Parse(result); title = jo["title"].Value <string>(); artist = jo["artist"].Value <string>(); image = jo["related_channel"]["cover"].Value <string>(); } catch { System.Diagnostics.Debug.WriteLine("get music details error."); title = ""; artist = ""; image = null; } }
private async Task InitListResourcesAsync(int list_id) { var result = is_daily? await DoubanWebProcess.GetMDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/songlist/user_daily/?version=644&app_name=radio_android&kbps=192&apikey={APIKey}", host : "api.douban.com", reffer : null, bearer : bearer, userAgt : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C"): await DoubanWebProcess.PostDoubanResponseAsync( path : $"{"https://"}api.douban.com/v2/fm/songlist/{list_id}/detail", host : "api.douban.com", reffer : null, userAgent : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C", content : new HttpFormUrlEncodedContent(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("version", "644"), new KeyValuePair <string, string>("kbps", "320"), new KeyValuePair <string, string>("app_name", "radio_android"), new KeyValuePair <string, string>("apikey", APIKey), }), bearer : bearer); try { var song_list = JsonHelper.FromJson <MHzSongList>(result); if (song_list.Cover == "") { song_list.Cover = "ms-appx:///Assets/231.jpg"; } inner_list = new ObservableCollection <MHzSong>(); song_list.Songs.ToList().ForEach(i => inner_list.Add(i)); var query = await StorageHelper.GetAllStorageFilesByExtensionAsync(StorageHelper.JsonExtension); foreach (var item in inner_list) { item.IsCached = StorageHelper.IsExistLocalJsonBySHA256(MHzSongBaseHelper.GetIdentity(item), query); } ListResources.Source = inner_list; SetListHeader(song_list); } catch { /* Ignore */ } finally { IncrementalLoadingBorder.SetVisibility(false); } }
public static async Task <bool> AddToRedHeartAsync(SongBase song, long list_id, string api_key, string bearer, Guid app_did, bool is_add = true) { var model = new RedHeartPost { Type = is_add ? "r" : "u", PlayMode = null, PlaySource = "n", SID = song.SID, Time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), PID = list_id }; IList <RedHeartPost> list = new List <RedHeartPost> { model }; var json = JsonHelper.ToJson(list); var content = new HttpFormUrlEncodedContent(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("version", "644"), new KeyValuePair <string, string>("records", json), new KeyValuePair <string, string>("app_name", "radio_android"), new KeyValuePair <string, string>("client", $"s:mobile|v:4.6.4|y:android 4.3|f:644|m:Taobao|d:{app_did}|e:tcl_tcl-p306c"), new KeyValuePair <string, string>("apikey", api_key), }); var result = default(string); try { result = await DoubanWebProcess.PostDoubanResponseAsync( $"{"https://"}api.douban.com/v2/fm/action_log?udid={app_did}", "api.douban.com", null, userAgent : @"api-client/2.0 com.douban.radio/4.6.4(464) Android/18 TCL_P306C TCL TCL-306C", content : content, bearer : bearer); } catch { return(false); } if (result.Contains(@"""r"":0")) { return(true); } else { return(false); } }
private async void RelativePanel_LoadedAsync(object sender, RoutedEventArgs e) { UserInfoDetails = this.DetailsFrame; UserInfoPopup = this.InnerContentPanel; if (UserId == null || UserId == LoginStatus.UserId) { UserNameBlock.Text = LoginStatus.UserName ?? ""; LocationBlock.Text = LoginStatus.LocationString ?? ""; DescriptionBlock.Text = (LoginStatus.Description?.Replace("\n", " ")) ?? ""; if (LoginStatus.APIUserinfos != null) { SetStateByLoginStatus(); } } else { try { var result = await DoubanWebProcess.GetAPIResponseAsync( path : "https://m.douban.com/rexxar/api/v2/user/" + UserId, host : "m.douban.com", reffer : "https://m.douban.com/mine/"); var resultBag = GlobalHelpers.GetLoginStatus(result); UserNameBlock.Text = resultBag.UserName ?? ""; LocationBlock.Text = resultBag.LocationString ?? ""; DescriptionBlock.Text = resultBag.Description.Replace("\n", " "); if (resultBag.APIUserinfos != null) { SetStateByLoginStatus(resultBag); } } catch { /* Ignore */ } } listBorder.Margin = new Thickness(0, 20 + Scroll.ActualHeight, 0, 0); listScroll = GlobalHelpers.GetScrollViewer(ContentList); listScroll.ViewChanged += ListScroll_OnViewChanged; }