You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.2 KiB

2 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Client-Side JavaScript Code Sample</title>
  5. <script src="/Scripts/3rd/jquery-2.1.3.min.js"></script>
  6. <script src="/Scripts/lib/Util.min.js"></script>
  7. <script src="/Scripts/constants.js"></script>
  8. <script src="//js.live.net/v5.0/wl.js"></script>
  9. <script src="/Scripts/Test_Calendar.js"></script>
  10. </head>
  11. <body>
  12. <div id="signin"></div>
  13. <label id="info"></label>
  14. <div>
  15. <input type="button" id="id1" value="读取日历属性" />
  16. <input type="button" id="id2" value="删除日历" />
  17. <input type="button" id="id3" value="创建日历" />
  18. <input type="button" id="id4" value="更新日历属性" />
  19. <input type="button" id="id5" value="读取日历事件" />
  20. <input type="button" id="id6" value="删除日历事件" />
  21. <input type="button" id="id7" value="创建日历事件" />
  22. <input type="button" id="id8" value="更新日历事件" />
  23. </div>
  24. <script>
  25. WL.Event.subscribe("auth.login", onLogin);
  26. WL.init({
  27. client_id: APP_CLIENT_ID,
  28. redirect_uri: REDIRECT_URL,
  29. scope: ["wl.signin", "wl.basic", "wl.birthday", "wl.emails", 'wl.calendars'],
  30. response_type: "token"
  31. });
  32. WL.ui({
  33. name: "signin",
  34. element: "signin"
  35. });
  36. function onLogin(session) {
  37. debugger
  38. if (!session.error) {
  39. WL.api({
  40. path: "me",
  41. method: "GET"
  42. }).then(
  43. function (response) {
  44. document.getElementById("info").innerText =
  45. "Hello, " + response.first_name + " " + response.last_name + "!";
  46. },
  47. function (responseFailed) {
  48. document.getElementById("info").innerText =
  49. "Error calling API: " + responseFailed.error.message;
  50. }
  51. );
  52. }
  53. else {
  54. document.getElementById("info").innerText =
  55. "Error signing in: " + session.error_description;
  56. }
  57. }
  58. </script>
  59. </body>
  60. </html>