瀏覽代碼

授权返回json

liuzejian 1 年之前
父節點
當前提交
71cafd0f13

+ 5 - 3
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -47,12 +47,14 @@ class WechatOpenPlatformController extends CatchController
         $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
         $app = WechatOpenPlatformService::buildApplication($componentInfo);
         $client = $app->getClient();
-        $response = $client->post('/cgi-bin/component/api_query_auth', [
+        $response = $client->postJson('/cgi-bin/component/api_query_auth', [
             'component_appid' => $component_appid,
             'authorization_code' => $auth_code
         ]);
-        $authorizer_appid = $response['authorization_info']['authorizer_appid'];
-        $authorizer_refresh_token = $response['authorization_info']['authorizer_refresh_token'];
+        $parsedContent = \json_decode($response->getContent(), true);
+        myLog('auth')->info('$parsedContent', $parsedContent);
+        $authorizer_appid = $parsedContent['authorization_info']['authorizer_appid'];
+        $authorizer_refresh_token = $parsedContent['authorization_info']['authorizer_refresh_token'];
 
         WechatAuthorizationInfo::updateOrCreate([
             'authorizer_appid' => $authorizer_appid,

+ 3 - 4
tests/Channel/Http/Controllers/WechatOpenPlatformControllerTest.php

@@ -12,10 +12,9 @@ class WechatOpenPlatformControllerTest extends UsedTestCase
 
     public function testAuth()
     {
-        DB::table('banks')
-            ->upsert([
-                ['name' => '比利时联合银行股份有限公司', 'is_show' => 1, 'code' => 651],
-            ], ['name'], ['is_show']);
+        $res = $this->withHeaders([
+        ])->json('get','http://localhost/api/channel/openPlatform/auth/wxf313b3506bac2647/26?auth_code=queryauthcode@@@K_MNMi2oLcnszHdG1o5R9rSYcrxFrBmTwtug04MDjk2PrjEfl1mVjYSfPSgJzodUyIvOKXnVaTtz-oLPUw10Ng&expires_in=3600');
+        $res->dump();
     }
     public function testauthorCommand()
     {