xiaogang 4 years ago
parent
commit
8d41129856
2 changed files with 17 additions and 3 deletions
  1. 16 3
      app/Http/Controllers/Api/UserController.php
  2. 1 0
      routes/api.php

+ 16 - 3
app/Http/Controllers/Api/UserController.php

@@ -290,9 +290,22 @@ class UserController extends Controller
     public function auth(Request $request){
     public function auth(Request $request){
         $apiFace = new \AipFace(env('BAI_DU_YUN_APP_ID'),env('BAI_DU_YUN_API_KEY'),env('BAI_DU_YUN_SECRET_KEY'));
         $apiFace = new \AipFace(env('BAI_DU_YUN_APP_ID'),env('BAI_DU_YUN_API_KEY'),env('BAI_DU_YUN_SECRET_KEY'));
 
 
-
-        $apiFace->match();
-
+        try {
+           $images = array(
+                array(
+                    'image' => base64_encode(file_get_contents('1.jpg')),
+                    'image_type' => 'BASE64',
+                ),
+                array(
+                    'image' => base64_encode(file_get_contents('2.jpg')),
+                    'image_type' => 'BASE64',
+                ),
+            );
+            $res = $apiFace->match($images);
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json($res);
     }
     }
 
 
 
 

+ 1 - 0
routes/api.php

@@ -102,6 +102,7 @@ $api->version('v1', [
             $api->post('/looked_me', 'UserController@looked_me')->name('user.looked_me');
             $api->post('/looked_me', 'UserController@looked_me')->name('user.looked_me');
             $api->get('/get_vip', 'UserController@get_vip')->name('user.get_vip');
             $api->get('/get_vip', 'UserController@get_vip')->name('user.get_vip');
             $api->post('/buy_vip', 'UserController@buy_vip')->name('user.buy_vip');
             $api->post('/buy_vip', 'UserController@buy_vip')->name('user.buy_vip');
+            $api->post('/auth', 'UserController@auth')->name('user.auth');
         });
         });
 
 
         /*
         /*