{"id":38,"date":"2025-04-20T21:15:19","date_gmt":"2025-04-20T13:15:19","guid":{"rendered":"https:\/\/log.d9t3.com\/?p=38"},"modified":"2025-04-20T21:16:52","modified_gmt":"2025-04-20T13:16:52","slug":"%e8%a7%a3%e5%86%b3%e5%be%ae%e4%bf%a1%e5%85%ac%e4%bc%97%e5%8f%b7%e7%bd%91%e9%a1%b5%e6%8e%88%e6%9d%83%e5%8f%aa%e8%83%bd%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%9b%9e%e8%b0%83%e5%9f%9f%e5%90%8d%e7%9a%84","status":"publish","type":"post","link":"https:\/\/log.d9t3.com\/?p=38","title":{"rendered":"\u89e3\u51b3\u5fae\u4fe1\u516c\u4f17\u53f7\u7f51\u9875\u6388\u6743\u53ea\u80fd\u8bbe\u7f6e\u4e00\u4e2a\u56de\u8c03\u57df\u540d\u7684\u95ee\u9898\u00a0"},"content":{"rendered":"\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<p>\u4e00\u4e2a\u516c\u4f17\u53f7\uff08\u670d\u52a1\u53f7\uff09\uff0c\u4e0b\u9762\u90e8\u7f72\u4e86\u591a\u4e2a\u9879\u76ee\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u90e8\u7f72\u5728\u4e0d\u4e00\u6837\u7684\u670d\u52a1\u5668\u4e0a\u9762\uff0c\u591a\u4e2a\u57df\u540d\u3002<\/p>\n\n\n\n<p>\u9700\u6c42\uff1a<\/p>\n\n\n\n<p>XX\u5de5\u4f5c\u5ba4\u516c\u4f17\u53f7\uff1a &nbsp;\u7535\u5546\u9996\u9875\u3001\u5fae\u4fe1\u8ba2\u8d2d\u4e24\u4e2a\u9879\u76ee\u90e8\u7f72<\/p>\n\n\n\n<p>\u9875\u9762\u4ee3\u7801\uff1aget-weixin-code.html<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\r\n&lt;html lang=\"en\">\n\n&lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;title>\u5fae\u4fe1\u767b\u5f55&lt;\/title>\n&lt;\/head>\n\n&lt;body>\n    &lt;script>\n        var GWC = {\n            version: '1.1.1',\n            urlParams: {},\n            appendParams: function(url, params) {\n                if (params) {\n                    var baseWithSearch = url.split('#')&#91;0];\n                    var hash = url.split('#')&#91;1];\n                    for (var key in params) {\n                        var attrValue = params&#91;key];\n                        if (attrValue !== undefined) {\n                            var newParam = key + \"=\" + attrValue;\n                            if (baseWithSearch.indexOf('?') > 0) {\n                                var oldParamReg = new RegExp('^' + key + '=&#91;-%.!~*\\'\\(\\)\\\\w]*', 'g');\n                                if (oldParamReg.test(baseWithSearch)) {\n                                    baseWithSearch = baseWithSearch.replace(oldParamReg, newParam);\n                                } else {\n                                    baseWithSearch += \"&amp;\" + newParam;\n                                }\n                            } else {\n                                baseWithSearch += \"?\" + newParam;\n                            }\n                        }\n                    }\n\n                    if (hash) {\n                        url = baseWithSearch + '#' + hash;\n                    } else {\n                        url = baseWithSearch;\n                    }\n                }\n                return url;\n            },\n            getUrlParams: function() {\n                var pairs = location.search.substring(1).split('&amp;');\n                for (var i = 0; i &lt; pairs.length; i++) {\n                    var pos = pairs&#91;i].indexOf('=');\n                    if (pos === -1) {\n                        continue;\n                    }\n                    GWC.urlParams&#91;pairs&#91;i].substring(0, pos)] = decodeURIComponent(pairs&#91;i].substring(pos + 1));\n                }\n            },\n            doRedirect: function() {\n                var code = GWC.urlParams&#91;'code'];\n                var appId = GWC.urlParams&#91;'appid'];\n                var scope = GWC.urlParams&#91;'scope'] || 'snsapi_base';\n                var state = GWC.urlParams&#91;'state'];\n                var redirectUri;\n\n                if (!code) {\n                    \/\/\u7b2c\u4e00\u6b65\uff0c\u6ca1\u6709\u62ff\u5230code\uff0c\u8df3\u8f6c\u81f3\u5fae\u4fe1\u6388\u6743\u9875\u9762\u83b7\u53d6code\n                    redirectUri = GWC.appendParams('https:\/\/open.weixin.qq.com\/connect\/oauth2\/authorize#wechat_redirect', {\n                        'appid': appId,\n                        'redirect_uri': encodeURIComponent(location.href),\n                        'response_type': 'code',\n                        'scope': scope,\n                        'state': state,\n                    });\n                } else {\n                    \/\/\u7b2c\u4e8c\u6b65\uff0c\u4ece\u5fae\u4fe1\u6388\u6743\u9875\u9762\u8df3\u8f6c\u56de\u6765\uff0c\u5df2\u7ecf\u83b7\u53d6\u5230\u4e86code\uff0c\u518d\u6b21\u8df3\u8f6c\u5230\u5b9e\u9645\u6240\u9700\u9875\u9762\n                    redirectUri = GWC.appendParams(GWC.urlParams&#91;'redirect_uri'], {\n                        'code': code,\n                        'state': state\n                    });\n                }\n\n                location.href = redirectUri;\n            }\n        };\n\n        GWC.getUrlParams();\n        GWC.doRedirect();\n    &lt;\/script>\n&lt;\/body>\n\n&lt;\/html><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><br>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n\n\n\n<ol>\n<li>\u90e8\u7f72<code>get-weixin-code.html<\/code>\u81f3\u4f60\u7684\u5fae\u4fe1\u6388\u6743\u56de\u8c03\u57df\u540d\u7684\u76ee\u5f55\u4e0b<\/li>\n\n\n\n<li>\u4f7f\u7528\u65b9\u5f0f\u7c7b\u4f3c\u4e8e\u76f4\u63a5\u901a\u8fc7\u5fae\u4fe1\u56de\u8c03\u7684\u65b9\u5f0f\uff0c\u53ea\u662f\u5c06\u56de\u8c03\u5730\u5740\u6539\u6210\u4e86<code>get-weixin-code.html<\/code>\u6240\u5728\u7684\u5730\u5740\uff0c\u53e6\u5916\u7701\u53bb\u4e86<code>response_type<\/code>\u53c2\u6570\uff08\u56e0\u4e3a\u5b83\u53ea\u80fd\u4e3a<code>code<\/code>\uff09\u4ee5\u53ca<code>#wechat_redirect<\/code>\uff08\u5b83\u662f\u56fa\u5b9a\u7684\uff09\uff0c\u5b83\u4eec\u4f1a\u5728<code>get-weixin-code.html<\/code>\u91cc\u9762\u81ea\u5df1\u52a0\u4e0a<\/li>\n\n\n\n<li><code>get-weixin-code.html<\/code>\u9875\u9762\u4ece\u5fae\u4fe1\u90a3\u91cc\u62ff\u5230code\u4e4b\u540e\u4f1a\u91cd\u65b0\u8df3\u8f6c\u56de<code>redirect_uri<\/code>\u91cc\u9762\u586b\u5199\u7684url\uff0c\u5e76\u4e14\u5728url\u540e\u9762\u5e26\u4e0a<code>code<\/code>\u548c<code>state<\/code><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/HADB\/GetWeixinCode#%E8%AF%A6%E7%BB%86%E7%A4%BA%E4%BE%8B\"><\/a>\u8be6\u7ec6\u793a\u4f8b<\/h2>\n\n\n\n<ol>\n<li>\u524d\u5f80\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0-&gt;\u63a5\u53e3\u6743\u9650-&gt;\u7f51\u9875\u6388\u6743\u83b7\u53d6\u7528\u6237\u57fa\u672c\u4fe1\u606f-&gt;\u4fee\u6539\uff0c\u586b\u5199\u6388\u6743\u56de\u8c03\u9875\u9762\u57df\u540d\uff0c\u4f8b\u5982<code>www.abc.com<\/code><\/li>\n\n\n\n<li>\u5728<code>www.abc.com<\/code>\u57df\u540d\u4e0b\u90e8\u7f72<code>get-weixin-code.html<\/code>\uff0c\u4e0d\u4e00\u5b9a\u662f\u6839\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a<code>http:\/\/www.abc.com\/xxx\/get-weixin-code.html<\/code><\/li>\n\n\n\n<li>\u5047\u8bbe\u4f60\u7684<code>http:\/\/www.xyz.com\/hello-world.html<\/code>\u8fd9\u4e2a\u9875\u9762\u9700\u8981\u83b7\u53d6\u5fae\u4fe1\u6388\u6743\uff0c\u90a3\u4e48\u4f60\u5e94\u8be5\u4f7f\u7528\u4ee5\u4e0b\u5730\u5740\u6765\u83b7\u53d6\u6388\u6743\uff1a<code>http:\/\/www.abc.com\/xxx\/get-weixin-code.html?appid=XXXX&amp;scope=snsapi_base&amp;state=hello-world&amp;redirect_uri=http%3A%2F%2Fwww.xyz.com%2Fhello-world.html<\/code><\/li>\n\n\n\n<li>\u8fd9\u6837\u6700\u7ec8\u5c31\u4f1a\u8df3\u8f6c\u5230\u8fd9\u6837\u4e00\u4e2a\u5730\u5740\uff1a<code>http:\/\/www.xyz.com\/hello-world.html?code=XXXXXXXXXXXXXXXXX&amp;state=hello-world<\/code>\uff0c\u4ece\u800c\u4f60\u5c31\u62ff\u5230\u4e86\u6388\u6743<code>code<\/code>\u4ee5\u53ca\u81ea\u5b9a\u4e49\u7684<code>state<\/code>\u53c2\u6570\u4e86<\/li>\n<\/ol>\n\n\n\n<p>eg\uff1a<\/p>\n\n\n\n<p>\u516c\u4f17\u53f7\u56de\u8c03\u5730\u5740\uff1awxcsh.edsl.com.cn<\/p>\n\n\n\n<p>\u9879\u76ee\u5730\u5740\uff1awxcs78.edsl.com.cn<\/p>\n\n\n\n<p>\u901a\u8fc7loginByWeixin.do\u63a5\u53e3\u53ef\u4ee5\u53d6\u5230\u5bf9\u5e94\u516c\u4f17\u53f7\u7684code\uff0c\u4ece\u800c\u83b7\u53d6openId<\/p>\n\n\n\n<p>http:\/\/wxcsh.edsl.com.cn\/get-weixin-code.html?appid=wxa63f33a8579fdf36&#038;scope=snsapi_base&#038;state=hello-world&#038;redirect_uri=http:\/\/wxcs78.edsl.com.cn\/user\/loginByWeixin.do<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u573a\u666f\uff1a \u4e00\u4e2a\u516c\u4f17\u53f7\uff08\u670d\u52a1\u53f7\uff09\uff0c\u4e0b\u9762\u90e8\u7f72\u4e86\u591a\u4e2a\u9879\u76ee\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u90e8\u7f72\u5728\u4e0d\u4e00\u6837\u7684\u670d\u52a1\u5668\u4e0a\u9762\uff0c\u591a\u4e2a\u57df\u540d\u3002 \u9700\u6c42\uff1a <\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"https:\/\/log.d9t3.com\/?p=38\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/posts\/38"}],"collection":[{"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=38"}],"version-history":[{"count":2,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":40,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions\/40"}],"wp:attachment":[{"href":"https:\/\/log.d9t3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.d9t3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}