allen 3 rokov pred
rodič
commit
49b972585a
4 zmenil súbory, kde vykonal 154 pridanie a 3929 odobranie
  1. 3 3
      .example.env
  2. 18 3
      app/index/controller/Index.php
  3. 5 4
      app/service/WeiboService.php
  4. 128 3919
      sql.sql

+ 3 - 3
.example.env

@@ -6,9 +6,9 @@ DEFAULT_TIMEZONE = Asia/Shanghai
 [DATABASE]
 TYPE = mysql
 HOSTNAME = 127.0.0.1
-DATABASE = sina
+DATABASE = video
 USERNAME = root
-PASSWORD = 
+PASSWORD =
 HOSTPORT = 3306
 CHARSET = utf8mb4
 DEBUG = true
@@ -34,4 +34,4 @@ API_SECRET=
 # 是否Mock掉对微博接口的请求,线上配置成0
 MOCK=
 # H5前端页面的域名,用于线上Referer检测
-REFERER=
+REFERER=

+ 18 - 3
app/index/controller/Index.php

@@ -2,6 +2,7 @@
 
 namespace app\index\controller;
 
+use think\db\Where;
 use think\facade\Db;
 use app\middleware\Log;
 use think\facade\Cache;
@@ -71,12 +72,26 @@ class Index extends Controller
         }
         FacadeLog::info($sub);
         $userInfoRes = (new WeiboService($uid))->userinfo($sub);
-        if (empty($userInfoRes) || $userInfoRes['code'] != 10000) {
+        if (empty($userInfoRes) || $userInfoRes['ok'] != 1) {
             return $this->response(403, $userInfoRes['msg'] ?? '没有登录');
         }
+
         // 使用客户端信息生成token
         $token = md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['HTTP_ACCEPT_ENCODING'] . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . $_SERVER['HTTP_REFERER'] . get_client_ip(0) . $userInfoRes['data']['uid']);
         $user = $userInfoRes['data'];
+
+        $userInfo = Db::table('awards_user_info')->where('uid', $user['uid'])->find();
+        if (empty($userInfo)) {
+            $userAttr = [
+                'uid' => $user['uid'],
+                'portrait' => $user['profile_image_url'],
+                'nickname' => $user['name']
+            ];
+            if (0 == Db::table('awards_user_info')->insert($userAttr)) {
+                return $this->response(5001, '系统错误,请稍后再试~');
+            }
+        }
+
         // 生成加密用的密钥和向量
         $cipher = "aes-256-gcm";
         $ivlen = openssl_cipher_iv_length($cipher);
@@ -117,12 +132,12 @@ class Index extends Controller
                 return $this->response(5001, '系统错误,请稍后再试~');
             }
         } else if ($userTask['finish_state'] == 0 && $userTask['share_add_votes'] == 0) {
-            $count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
+            $count = Db::table('awards_user_task_log')->where('uid', $user['uid'])->where('date', $date)->count('id');
             if ($count < 1) {
                 $first = 1;
             }
         } else if ($userTask['finish_state'] > 0 && $userTask['share_add_votes'] > 0) {
-            $count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->where('date', $date)->count('id');
+            $count = Db::table('awards_user_task_log')->where('uid', $user['uid'])->where('date', $date)->count('id');
             if ($count < 2) {
                 $first = 1;
             }

+ 5 - 4
app/service/WeiboService.php

@@ -49,7 +49,6 @@ class WeiboService
         $this->appKey = env('weibo.api_key', 'h5vote');
         $this->appSecret = env('weibo.api_secret', '8d6967d654bca47a');
         $this->time = time();
-        $this->signStr = $this->signStr($this->time, $uid);
         static::$base_url = env('weibo.api_host', 'https://ent.weibo.cn/open/wmac/');
     }
 
@@ -241,8 +240,8 @@ class WeiboService
                 ],
             ];
         }
-        $url = self::$base_url . 'user'. '?sign=' . $this->signStr . '&sub=' . $sub . '&time='.$this->time.'&secret='.$this->appSecret;
-
+        $this->signStr = $this->signStr($this->time, $sub);
+        $url = self::$base_url . 'token'. '?sign=' . $this->signStr . '&sub=' . $sub . '&time='.$this->time.'&secret=8d6967d654bca47a';
         return self::_httpGet($url);
     }
 
@@ -251,6 +250,8 @@ class WeiboService
      */
     private function signStr($time, $sub)
     {
-        return md5($time>>8 . $this->appSecret . $sub);
+        $str = ($time>>8) . "8d6967d654bca47a" . $sub;
+        FacadeLog::info('signStr: '.$str);
+        return md5($str);
     }
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 128 - 3919
sql.sql


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov