{"id":29256,"date":"2024-11-25T10:03:40","date_gmt":"2024-11-25T02:03:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29256\/"},"modified":"2024-11-25T10:03:40","modified_gmt":"2024-11-25T02:03:40","slug":"%e8%af%a6%e8%a7%a3%e5%be%ae%e4%bf%a1js-sdk%e5%bc%80%e5%8f%91%e6%89%ab%e4%b8%80%e6%89%ab%e6%8e%a5%e5%8f%a3%e5%8a%9f%e8%83%bd%e5%ae%9e%e7%8e%b0%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29256\/","title":{"rendered":"\u8be6\u89e3\u5fae\u4fe1JS-SDK\u5f00\u53d1\u626b\u4e00\u626b\u63a5\u53e3\u529f\u80fd\u5b9e\u73b0\u4ee3\u7801"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u8be6\u89e3\u5fae\u4fe1js-sdk\u5f00\u53d1\u626b\u4e00\u626b\u63a5\u53e3\u529f\u80fd\u5b9e\u73b0\u4ee3\u7801<\/p>\n<pre>&lt;?php     require_once \"jssdk.php\";\r\n    $appID = \"\u8f93\u5165\u4f60\u7684id\";\r\n     $appsecret = \"\u8f93\u5165\u4f60\u7684secret\";\r\n \r\n    $jssdk = new JSSDK($appID, $appsecret);\r\n    $signPackage = $jssdk-&gt;GetSignPackage();\r\nvar_dump($jssdk);\r\n&nbsp;&nbsp;&nbsp;\r\n?&amp;gt;\r\nnbsp;html&amp;gt;\r\n\r\n\r\n&nbsp;&nbsp;&lt;meta&gt;\r\n&nbsp;&nbsp;&lt;title&gt;&lt;\/title&gt;\r\n&nbsp;&nbsp;&lt;input&gt;\"&nbsp;id=\"id1\"&nbsp;\/&amp;gt;\r\n&nbsp;&nbsp;&lt;input&gt;\"id=\"id2\"&nbsp;\/&amp;gt;\r\n&nbsp;&nbsp;&lt;input&gt;\"&nbsp;id=\"id3\"&nbsp;\/&amp;gt;\r\n&nbsp;&nbsp;&lt;input&gt;\"&nbsp;id=\"id4\"&nbsp;\/&amp;gt;\r\n\r\n&lt;script&gt;&lt;\/script&gt;&lt;script&gt;&lt;\/script&gt;&lt;script&gt;\r\n  \/\/ \u6ce8\u610f\uff1a\u6240\u6709\u7684JS\u63a5\u53e3\u53ea\u80fd\u5728\u516c\u4f17\u53f7\u7ed1\u5b9a\u7684\u57df\u540d\u4e0b\u8c03\u7528\uff0c\u516c\u4f17\u53f7\u5f00\u53d1\u8005\u9700\u8981\u5148\u767b\u5f55\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u5165\u201c\u516c\u4f17\u53f7\u8bbe\u7f6e\u201d\u7684\u201c\u529f\u80fd\u8bbe\u7f6e\u201d\u91cc\u586b\u5199\u201cJS\u63a5\u53e3\u5b89\u5168\u57df\u540d\u201d\u3002 \r\n  \/\/ \u5982\u679c\u53d1\u73b0\u5728 Android \u4e0d\u80fd\u5206\u4eab\u81ea\u5b9a\u4e49\u5185\u5bb9\uff0c\u8bf7\u5230\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684\u5305\u8986\u76d6\u5b89\u88c5\uff0cAndroid \u81ea\u5b9a\u4e49\u5206\u4eab\u63a5\u53e3\u9700\u5347\u7ea7\u81f3 6.0.2.58 \u7248\u672c\u53ca\u4ee5\u4e0a\u3002\r\n  \/\/ \u5b8c\u6574 JS-SDK \u6587\u6863\u5730\u5740\uff1ahttp:\/\/mp.weixin.qq.com\/wiki\/7\/aaa137b55fb2e0456bf8dd9148dd613f.html\r\n  var appId=$(&#039;#id1&#039;).val();\r\n  var timestamp=$(&#039;#id2&#039;).val();\r\n  var nonceStr=$(&#039;#id3&#039;).val();\r\n  var signature=$(&#039;#id4&#039;).val();\r\n  wx.config({\r\n    debug: true,\r\n    appId: appId,\r\n    timestamp: timestamp,\r\n    nonceStr: nonceStr,\r\n    signature: signature,\r\n    jsApiList: \r\n       \/\/ \u6240\u6709\u8981\u8c03\u7528\u7684 API \u90fd\u8981\u52a0\u5230\u8fd9\u4e2a\u5217\u8868\u4e2d\r\n       [&#039;scanQRCode&#039;]\r\n     \r\n  });\r\n   wx.ready(function () {\r\n     \/\/ \u5728\u8fd9\u91cc\u8c03\u7528 API\r\n     alert(1);\r\nwx.checkJsApi({\r\n    jsApiList: [&#039;chooseImage&#039;], \/\/ \u9700\u8981\u68c0\u6d4b\u7684JS\u63a5\u53e3\u5217\u8868\uff0c\u6240\u6709JS\u63a5\u53e3\u5217\u8868\u89c1\u9644\u5f552,\r\n    success: function(res) {\r\n     alert(res.errMsg);\r\n        \/\/ \u4ee5\u952e\u503c\u5bf9\u7684\u5f62\u5f0f\u8fd4\u56de\uff0c\u53ef\u7528\u7684api\u503ctrue\uff0c\u4e0d\u53ef\u7528\u4e3afalse\r\n       \/\/ {\"checkResult\":{\"chooseImage\":true},\"errMsg\":\"checkJsApi:ok\"}\r\n    }\r\n});\r\n       wx.scanQRCode({  \r\n     needResult: 0, \/\/ \u9ed8\u8ba4\u4e3a0\uff0c\u626b\u63cf\u7ed3\u679c\u7531\u5fae\u4fe1\u5904\u7406\uff0c1\u5219\u76f4\u63a5\u8fd4\u56de\u626b\u63cf\u7ed3\u679c\uff0c\r\n      scanType: [\"qrCode\",\"barCode\"], \/\/ \u53ef\u4ee5\u6307\u5b9a\u626b\u4e8c\u7ef4\u7801\u8fd8\u662f\u4e00\u7ef4\u7801\uff0c\u9ed8\u8ba4\u4e8c\u8005\u90fd\u6709\r\n      success: function (res) {\r\n       \r\n          var result = res.resultStr; \/\/ \u5f53needResult \u4e3a 1 \u65f6\uff0c\u626b\u7801\u8fd4\u56de\u7684\u7ed3\u679c\r\n      }\r\n      \r\n    })\r\n   });\r\n&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>\u4ee3\u7801\u653e\u5230\u670d\u52a1\u5668\u4e0a\u540e\u7528\u706b\u72d0\u6d4f\u89c8\u5668\u6253\u5f00\u94fe\u63a5\uff0c\u5728\u706b\u72d0\u6d4f\u89c8\u5668\u5730\u5740\u680f\u540e\u9762\u6709\u4e2a\u4e8c\u7ef4\u7801\u7684\u56fe\u6807\uff0c\u70b9\u51fb\u540e\u51fa\u73b0\u4e8c\u7ef4\u7801\u56fe\u7247\r\n\u7528\u5fae\u4fe1\u626b\u7801\u4e8c\u7ef4\u7801\uff0c\u5fae\u4fe1\u4e2d\u5f39\u51fa\u7684\u7f51\u9875\u4f1a\u6709\u8fd4\u56de\u503c\u3002\uff08\u7528\u5fae\u4fe1\u7684\u6d4f\u89c8\u5668\u6253\u5f00\uff09<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8be6\u89e3\u5fae\u4fe1JS-SDK\u5f00\u53d1\u626b\u4e00\u626b\u63a5\u53e3\u529f\u80fd\u5b9e\u73b0\u4ee3\u7801\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u8be6\u89e3\u5fae\u4fe1js-sdk\u5f00\u53d1\u626b\u4e00\u626b\u63a5\u53e3\u529f\u80fd\u5b9e\u73b0\u4ee3\u7801 &lt;?php require_once &#8220;jssdk.php&#8221;; $appID = &#8220;\u8f93\u5165\u4f60\u7684id&#8221;; $appsecret = &#8220;\u8f93\u5165\u4f60\u7684secret&#8221;; $jssdk = new JSSDK($appID, $appsecret); $signPackage = $jssdk-&gt;GetSignPackage(); var_dump($jssdk); &nbsp;&nbsp;&nbsp; ?&amp;gt; nbsp;html&amp;gt; &nbsp;&nbsp;&lt;meta&gt; &nbsp;&nbsp;&lt;title&gt;&lt;\/title&gt; &nbsp;&nbsp;&lt;input&gt;&#8221;&nbsp;id=&#8221;id1&#8243;&nbsp;\/&amp;gt; &nbsp;&nbsp;&lt;input&gt;&#8221;id=&#8221;id2&#8243;&nbsp;\/&amp;gt; &nbsp;&nbsp;&lt;input&gt;&#8221;&nbsp;id=&#8221;id3&#8243;&nbsp;\/&amp;gt; &nbsp;&nbsp;&lt;input&gt;&#8221;&nbsp;id=&#8221;id4&#8243;&nbsp;\/&amp;gt; &lt;script&gt;&lt;\/script&gt;&lt;script&gt;&lt;\/script&gt;&lt;script&gt; \/\/ \u6ce8\u610f\uff1a\u6240\u6709\u7684JS\u63a5\u53e3\u53ea\u80fd\u5728\u516c\u4f17\u53f7\u7ed1\u5b9a\u7684\u57df\u540d\u4e0b\u8c03\u7528\uff0c\u516c\u4f17\u53f7\u5f00\u53d1\u8005\u9700\u8981\u5148\u767b\u5f55\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u5165\u201c\u516c\u4f17\u53f7\u8bbe\u7f6e\u201d\u7684\u201c\u529f\u80fd\u8bbe\u7f6e\u201d\u91cc\u586b\u5199\u201cJS\u63a5\u53e3\u5b89\u5168\u57df\u540d\u201d\u3002 \/\/ \u5982\u679c\u53d1\u73b0\u5728 Android \u4e0d\u80fd\u5206\u4eab\u81ea\u5b9a\u4e49\u5185\u5bb9\uff0c\u8bf7\u5230\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684\u5305\u8986\u76d6\u5b89\u88c5\uff0cAndroid \u81ea\u5b9a\u4e49\u5206\u4eab\u63a5\u53e3\u9700\u5347\u7ea7\u81f3 6.0.2.58 \u7248\u672c\u53ca\u4ee5\u4e0a\u3002 \/\/ \u5b8c\u6574 JS-SDK \u6587\u6863\u5730\u5740\uff1ahttp:\/\/mp.weixin.qq.com\/wiki\/7\/aaa137b55fb2e0456bf8dd9148dd613f.html var appId=$(&#039;#id1&#039;).val(); var timestamp=$(&#039;#id2&#039;).val(); var nonceStr=$(&#039;#id3&#039;).val(); var signature=$(&#039;#id4&#039;).val(); wx.config({ debug: true, appId: appId, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-29256","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29256"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29256\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}