{"id":25,"date":"2025-06-18T09:28:30","date_gmt":"2025-06-18T01:28:30","guid":{"rendered":"https:\/\/3sheep.ip2.ltd\/?p=25"},"modified":"2025-06-18T09:33:25","modified_gmt":"2025-06-18T01:33:25","slug":"%e8%bf%98%e5%9c%a8%e4%b8%ba%e5%a4%9a%e4%b8%aa%e7%bd%91%e7%ab%99%e6%89%ab%e7%a0%81%e6%8e%88%e6%9d%83%e6%8a%93%e7%8b%82%ef%bc%9f%e4%b8%80%e6%8b%9b%e6%90%9e%e5%ae%9a%e6%89%80%e6%9c%89%e5%9f%9f%e5%90%8d","status":"publish","type":"post","link":"https:\/\/3sheep.ip2.ltd\/index.php\/2025\/06\/18\/%e8%bf%98%e5%9c%a8%e4%b8%ba%e5%a4%9a%e4%b8%aa%e7%bd%91%e7%ab%99%e6%89%ab%e7%a0%81%e6%8e%88%e6%9d%83%e6%8a%93%e7%8b%82%ef%bc%9f%e4%b8%80%e6%8b%9b%e6%90%9e%e5%ae%9a%e6%89%80%e6%9c%89%e5%9f%9f%e5%90%8d\/","title":{"rendered":"\u8fd8\u5728\u4e3a\u591a\u4e2a\u7f51\u7ad9\u626b\u7801\u6388\u6743\u6293\u72c2\uff1f\u4e00\u62db\u641e\u5b9a\u6240\u6709\u57df\u540d\u767b\u5f55\uff01"},"content":{"rendered":"\n<p><strong>\u201c\u4e00\u70b9\u4e00\u626b\uff0c\u79d2\u56de\u7545\u767b\uff01<\/strong><br>\u5728A\u7f51\u7ad9\u70b9\u51fb\u767b\u5f55 \u2192 <strong>\u79d2\u8df3\u5b89\u5168\u9a8c\u8bc1\u9875 \u2192 \u624b\u673a\u8f7b\u677e\u626b\u7801 \u2192 \u77ac\u95f4\u81ea\u52a8\u8fd4\u56deA\u7ad9\uff01<\/strong><br>\u5168\u7a0b\u514d\u8f93\u5bc6\u7801\uff0c\u767b\u5f55\u5982\u4e1d\u822c\u987a\u6ed1\uff0c\u5b89\u5168\u53c8\u7701\u5fc3~ \u201d<\/p>\n\n\n\n<p>\u521b\u5efabottom\u7684link<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;auth.sunyee.site\/wechat-login.php<\/code><\/pre>\n\n\n\n<p>B\u7ad9\u70b9\u5e26php\u521b\u5efaweixin-login.php<\/p>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ wechat-login.php\n$appid = 'wxxxxxx';\n$redirect_uri = urlencode('https:\/\/A\u7ad9\u70b9\/wechat-callback.php');\n$scope = 'snsapi_login'; \/\/ \u7f51\u7ad9\u5e94\u7528\u5fc5\u987b\u662f snsapi_login\n$state = 'state123'; \/\/ \u53ef\u81ea\u5b9a\u4e49\n\n$url = \"https:\/\/open.weixin.qq.com\/connect\/qrconnect?appid=$appid&amp;redirect_uri=$redirect_uri&amp;response_type=code&amp;scope=$scope&amp;state=$state#wechat_redirect\";\nheader(\"Location: $url\");\nexit;\n<\/code><\/pre>\n\n\n\n<p>A\u7ad9\u662fWordpress\u6839\u76ee\u5f55\u4e0b\u521b\u5efawechat-callback.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nrequire_once('wp-load.php');\n\n\n$appid = 'wxxxxx';\n$appsecret = 'aexxxxx';\n\n\n$code = $_GET&#91;'code'];\nif (!$code) exit('\u672a\u83b7\u53d6 code');\n\n$url = \"https:\/\/api.weixin.qq.com\/sns\/oauth2\/access_token?appid={$appid}&amp;secret={$appsecret}&amp;code={$code}&amp;grant_type=authorization_code\";\n$response = file_get_contents($url);\n$data = json_decode($response, true);\n\nif (!isset($data&#91;'openid'])) {\n    exit('\u5fae\u4fe1\u6388\u6743\u5931\u8d25\uff1a' . $response);\n}\n\n$openid = $data&#91;'openid'];\n$unionid = isset($data&#91;'unionid']) ? $data&#91;'unionid'] : null;\n\n\/\/ \u67e5\u8be2 WordPress \u7528\u6237\u662f\u5426\u5b58\u5728\n$user = get_users(&#91;\n    'meta_key' =&gt; 'wechat_openid',\n    'meta_value' =&gt; $openid,\n    'number' =&gt; 1\n]);\n\nif ($user) {\n    \/\/ \u767b\u5f55\u5df2\u6709\u7528\u6237\n    wp_set_current_user($user&#91;0]-&gt;ID);\n    wp_set_auth_cookie($user&#91;0]-&gt;ID);\n    wp_redirect(home_url());\n    exit;\n} else {\n    \/\/ \u521b\u5efa\u65b0\u7528\u6237\n    $username = 'wx_' . wp_generate_password(6, false);\n    $password = wp_generate_password();\n    $user_id = wp_create_user($username, $password);\n    update_user_meta($user_id, 'wechat_openid', $openid);\n    if ($unionid) update_user_meta($user_id, 'wechat_unionid', $unionid);\n\n    \/\/ \u767b\u5f55\n    wp_set_current_user($user_id);\n    wp_set_auth_cookie($user_id);\n    wp_redirect(home_url());\n    exit;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u201c\u4e00\u70b9\u4e00\u626b\uff0c\u79d2\u56de\u7545\u767b\uff01\u5728A\u7f51\u7ad9\u70b9\u51fb\u767b\u5f55 \u2192 \u79d2\u8df3\u5b89\u5168\u9a8c\u8bc1\u9875 \u2192 \u624b\u673a\u8f7b\u677e\u626b\u7801 \u2192 \u77ac\u95f4\u81ea\u52a8\u8fd4\u56deA\u7ad9\uff01\u5168\u7a0b\u514d\u8f93\u5bc6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","vk_price":""},"categories":[1],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":3,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3sheep.ip2.ltd\/index.php\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}