{"id":1348,"date":"2024-12-12T07:15:05","date_gmt":"2024-12-12T07:15:05","guid":{"rendered":"https:\/\/robinluo.top\/?p=1348"},"modified":"2024-12-12T08:26:55","modified_gmt":"2024-12-12T08:26:55","slug":"laravel-wechat","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=1348","title":{"rendered":"laravel wechat"},"content":{"rendered":"\n<p><strong>\u7528\u6237\u767b\u5f55\u6d41\u7a0b<\/strong>\uff1a<\/p>\n\n\n\n<p>\u5c0f\u7a0b\u5e8f\u8c03\u7528 wx.login \u540e\u83b7\u5f97 code \uff0c\u8c03\u7528 laravel-wechat \u7684login \u63a5\u53e3<\/p>\n\n\n\n<p><a href=\"https:\/\/depscreen.studentvision.cn\/api\/wechat\/mini\/login\">https:\/\/depscreen.studentvision.cn\/api\/wechat\/mini\/login<\/a><\/p>\n\n\n\n<p>\u8fd4\u56de \u7528\u6237\u4e2a\u4eba\u4fe1\u606f openid accessToken \u7b49<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\r\n\t\"error_code\": 0,\r\n\t\"data\": {\r\n\t\t\"access_token\": \"bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2RlcHNjcmVlbi5zdHVkZW50dmlzaW9uLmNuL2FwaS93ZWNoYXQvbWluaS9sb2dpbiIsImlhdCI6MTczMzk4NzMzMCwiZXhwIjoxNzMzOTkwOTMwLCJuYmYiOjE3MzM5ODczMzAsImp0aSI6IkFUTTloR1dvU1VuNjlaWWgiLCJzdWIiOiIxIiwicHJ2IjoiNDI1MTRkODBlZTM4NWRhODRjYTM4YWY0NTgyZThmNTRiYjRjZmIzOSJ9.qLXirUDL8GJjkg3LS47_J1LEpdA5j02VgyfUrt6RrpY\",\r\n\t\t\"expires_in\": 3600,\r\n\t\t\"wechat_user\": {\r\n\t\t\t\"id\": 1,\r\n\t\t\t\"app_id\": \"wx621e0fe15a370854\",\r\n\t\t\t\"user_id\": \"0\",\r\n\t\t\t\"openid\": \"oLG3w68wIQoTn5BwLOVyREIMtiFM\",\r\n\t\t\t\"nickname\": null,\r\n\t\t\t\"avatar\": null,\r\n\t\t\t\"gender\": \"0\",\r\n\t\t\t\"country\": null,\r\n\t\t\t\"province\": null,\r\n\t\t\t\"city\": null,\r\n\t\t\t\"subscribed_at\": null,\r\n\t\t\t\"created_at\": \"2024-12-11T04:15:17.997000Z\",\r\n\t\t\t\"updated_at\": \"2024-12-11T04:15:17.997000Z\",\r\n\t\t\t\"gender_readable\": null\r\n\t\t}\r\n\t}\r\n}<\/code><\/pre>\n\n\n\n<p>\u4e4b\u540e\u7684\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u8981\u5e26\u4e0a \u8be5jwt access token \u4f5c\u4e3a\u901a\u4fe1\u7968\u636e\u4ee5\u4fdd\u8bc1\u5b89\u5168<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Accept:application\/json\r\nContent-Type:application\/json\r\nAuthorization:bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2RlcHNjcmVlbi5zdHVkZW50dmlzaW9uLmNuL2FwaS93ZWNoYXQvbWluaS9sb2dpbiIsImlhdCI6MTczMzk4NzMzMCwiZXhwIjoxNzMzOTkwOTMwLCJuYmYiOjE3MzM5ODczMzAsImp0aSI6IkFUTTloR1dvU1VuNjlaWWgiLCJzdWIiOiIxIiwicHJ2IjoiNDI1MTRkODBlZTM4NWRhODRjYTM4YWY0NTgyZThmNTRiYjRjZmIzOSJ9.qLXirUDL8GJjkg3LS47_J1LEpdA5j02VgyfUrt6RrpY<\/code><\/pre>\n\n\n\n<p>controller \u589e\u52a0\u4e00\u4e2amiddleware \u4f5c\u4e3achecking<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Route::middleware('auth:mini')\n\n\u5177\u4f53\u5b9e\u73b0\u7c7b\u662f\n\u8fd9\u4e2a\u4f5c\u4e3ajwt\u5165\u53e3\n Tymon\\JWTAuth\\Providers\\LaravelServiceProvider::class,<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> php artisan  jwt:secret\r<\/code><\/pre>\n\n\n\n<p>\u8be5\u547d\u4ee4\u53ef\u4ee5\u91cd\u65b0\u751f\u6210jwt \u79c1\u94a5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u6237\u767b\u5f55\u6d41\u7a0b\uff1a \u5c0f\u7a0b\u5e8f\u8c03\u7528 wx.login \u540e\u83b7\u5f97 code \uff0c\u8c03\u7528 laravel-wechat \u7684login \u63a5\u53e3 https:\/\/depscreen.studentvision.cn\/api\/wechat\/mini\/login \u8fd4\u56de \u7528\u6237\u4e2a\u4eba\u4fe1\u606f openid accessToken \u7b49 \u4e4b\u540e\u7684\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u8981\u5e26\u4e0a \u8be5jwt access token \u4f5c\u4e3a\u901a\u4fe1\u7968\u636e\u4ee5\u4fdd\u8bc1\u5b89\u5168 controller \u589e\u52a0\u4e00\u4e2amiddleware \u4f5c\u4e3achecking \u8be5\u547d\u4ee4\u53ef\u4ee5\u91cd\u65b0\u751f\u6210jwt \u79c1\u94a5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[10,201],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1348"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1348"}],"version-history":[{"count":4,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions"}],"predecessor-version":[{"id":1352,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions\/1352"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}