WallpaperTool.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Azylee.Jsons;
  2. using Azylee.YeahWeb.HttpUtils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Text;
  8. namespace Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils
  9. {
  10. /// <summary>
  11. /// Bing壁纸工具类
  12. /// </summary>
  13. public static class WallpaperTool
  14. {
  15. // 图片尺寸信息
  16. // 1920x1200 1920x1080 1366x768 1280x768
  17. // 1024x768 800x600 800x480 768x1280
  18. // 720x1280 640x480 480x800 400x240
  19. // 320x240 240x320
  20. const string URL = "https://cn.bing.com/HPImageArchive.aspx?format=js&idx={0}&n=8";
  21. /// <summary>
  22. /// 获取今天的壁纸
  23. /// </summary>
  24. /// <returns></returns>
  25. public static WallpaperModel GetToday()
  26. {
  27. return GetSomeday(0);
  28. }
  29. /// <summary>
  30. /// 获取昨天的壁纸
  31. /// </summary>
  32. /// <returns></returns>
  33. public static WallpaperModel GetYesterday()
  34. {
  35. return GetSomeday(1);
  36. }
  37. /// <summary>
  38. /// 获取某一天的壁纸(每天8张)
  39. /// </summary>
  40. /// <param name="day"></param>
  41. /// <returns></returns>
  42. public static WallpaperModel GetSomeday(int day)
  43. {
  44. WallpaperModel model = null;
  45. try
  46. {
  47. string rs = HttpTool.Get(string.Format(URL, day));
  48. model = Json.String2Object<WallpaperModel>(rs);
  49. return model;
  50. }
  51. catch (Exception e) { return null; }
  52. }
  53. }
  54. }