index.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>测试用页面</title>
  6. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  7. <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
  8. <style>
  9. div, a {
  10. font-size: 60px;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div>
  16. <a onclick="getMsgByWX()">获取微信数据</a>
  17. </div>
  18. <br>
  19. <div>
  20. <a onclick="getMsgByWB()">获取微博数据</a>
  21. </div>
  22. <script>
  23. function getMsgByWX() {
  24. }
  25. function getMsgByWB() {
  26. }
  27. (function() {
  28. if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
  29. var ua = navigator.userAgent.toLowerCase() , url = "";
  30. // if (ua.match(/MicroMessenger/i) == "micromessenger") {
  31. alert("微信浏览器中打开");
  32. url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
  33. +"appid=wx749c84daac654e1e&"
  34. +"redirect_uri=wx.ttkuaiban.com&"
  35. +"response_type=code&"
  36. +"scope=snsapi_base&"
  37. +"state=STATE#wechat_redirect";
  38. //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx749c84daac654e1e&redirect_uri=wx.ttkuaiban.com&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect
  39. // }
  40. if (ua.match(/WeiBo/i) == "weibo") {
  41. alert("在新浪微博客户端打开");
  42. url = "https://api.weibo.cn/oauth2/authorize?"
  43. +"client_id=2141531565&"
  44. +"display=mobile&"
  45. +"response_type=code&"
  46. +"redirect_uri=code&"
  47. +"scope=snsapi_base";
  48. }
  49. //window.location.href = url;
  50. $.get(url ,function(data,status){
  51. console.log("Data: " + data + "nStatus: " + status);
  52. $.post("demo_ajax_gethint.html",{suggest:txt},function(result){
  53. $("span").html(result);
  54. });
  55. });
  56. }
  57. })()
  58. </script>
  59. </body>
  60. </html>