Sfoglia il codice sorgente

视频接口迁移

lizhen_gitee 10 mesi fa
parent
commit
cf81fd7d52

+ 4 - 0
application/api/controller/Index.php

@@ -17,6 +17,10 @@ class Index extends Api
     protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo', 'position', 'gamelist', 'special_models', 'app_error','indexdata','tudingc'];
     protected $noNeedRight = ['*'];
 
+    public function __construct(){
+        $this->error('老接口全部停用');
+    }
+
     /**
      * 首页
      *

+ 184 - 0
application/api/controller/Tvindex.php

@@ -424,7 +424,191 @@ class Tvindex extends Api
         $this->success('操作成功');
     }
 
+    //用户观看行为(支付)
+    public function payuserplay() {
+        $id = input('id', 0, 'intval'); //视频id
+        $sn = input('sn', '', 'trim'); //SN号
+        $start_time = input('start_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目开始播放时间
+        $end_time = input('end_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目结束播放时间,如果播放未结束,但是此时需要同步数据,填当前时间
+        $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5、其他
+
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+
+        $content = [
+            'UserID' => $this->auth->mobile,
+            'city' => '14',
+            'start_time' => $start_time,
+            'end_time' => $end_time,
+            'service_type' => 1,
+            'albumid' => $id,
+            'albumname' => $info['title'],
+            'csource' => $csource,
+            'SN' => $sn,
+            'ip' => request()->ip(),
+            'fee_type' => $info['is_pay'] == 1 ? 1 : '',
+            'flow' => '',
+            'product' => '',
+            'product_name' => '',
+            'info_source' => '02'
+        ];
+
+        $content = join('|', $content);
+
+        $filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.dat';
+        $check_filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.chk';
+
+        error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+        error_log('', 3, './dashuju/' . $check_filename);
+
+        $this->success('');
+    }
+
+    //视频播放记录
+    public function playrecord() {
+        $id = input('id', 0, 'intval');
+        $total_time = input('total_time', 0, 'intval'); //总时长
+        $start_time = input('start_time', 0, 'intval'); //开始看时间:相对时间
+        $end_time = input('end_time', 0, 'intval'); //结束看时间:相对时间
+        $log_type = input('log_type', 'watching', 'trim'); //begin:开始播放;watching:正在播放;end:结束播放
+
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+        if ($info['inject_status'] != 2) {
+            $this->error('视频丢失');
+        }
+
+        $info['image'] = one_domain_image($info['image']);
+
+        $url = 'http://meta-history.unso.gitv.tv/OTT/jscmcc/addThirdPartyHistoryRecord';
+        $content = [
+            'cpPrvdName' => '健康e家',
+            'cpPrvCode' => '41000144',
+            'cpPrvType' => '1006',
+            'contentName' => $info['title'],
+            'ChnName' => '健康',
+            'ChnCode' => '1000020',
+            'contentId' => (string)$info['movieid'],
+            'extraContentID' => '',
+            'isEffective' => $info['status'],
+            'isPaid' => $info['is_pay'],
+            'contentTotalTime' => $total_time,
+            'startWatchTime' => $start_time,
+            'endWatchTime' => $end_time,
+            'playTime' => $end_time - $start_time,
+            'logType' => $log_type,
+            'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
+            'cpPermission' => 'GITV',
+            'intent' => [
+                'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
+                'package' => 'com.huxiu.heh.tv',
+                'component' => [
+                    'pkg' => 'com.huxiu.heh.tv',
+                    'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
+                ],
+                'extras' => [
+                    /*'cmd' => '',
+                    'from' => '',
+                    'media_id' => ''*/
+                    'type_id' => $info['video_type_id'],
+                    'id' => $info['id']
+                ]
+            ],
+            'imageURL' => $info['image']
+        ];
+
+        $content = json_encode($content, 320);
+
+        $rt = httpRequest($url, 'POST', $content);
+        file_put_contents('bofang.txt',$id.'_'.$rt.PHP_EOL, FILE_APPEND);
+        if (!$rt) {
+            $this->error('同步失败');
+        }
+        $rt = json_decode($rt, true);
+        if ($rt['code'] != 0) {
+            $this->error('同步失败');
+        }
+
+        $this->success('同步成功');
+    }
+
+    //用户观看行为(大数据)
+    public function userplay() {
+        $id = input('id', 0, 'intval'); //视频id
+        $sn = input('sn', '', 'trim'); //SN号
+        $start_time = input('start_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目开始播放时间
+        $end_time = input('end_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目结束播放时间
+        $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5:从猜你喜欢个性化推荐页面访问(带上推荐接口的trace_id)99:其他
+        $trace_id = input('trace_id', '', 'trim');
+        $istry = input('istry', 0, 'intval'); //0非试看 1试看
+        $start_posi = input('start_posi', 0, 'intval'); //播放起始点相对于影片起始点的时长,单位秒,例如从影片第 600 秒开始观看
 
+        if (!$id) {
+            $this->error('您的网络开小差了');
+        }
+
+        $info = Db::name('video')->where(['id' => $id])->find();
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+
+        $content = [
+            'playid' => (string)(config('data_cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
+            'UserID' => $this->auth->mobile,
+            'SN' => $sn,
+            'start_time' => $start_time,
+            'end_time' => $end_time,
+            'service_type' => 1,
+            'cpid' => config('data_cp_id'),
+            'albumid' => $id,
+            'albumname' => $info['title'],
+            'videoid' => $id,
+            'videoname' => $info['title'],
+            'csource' => $csource,
+            'trace_id' => $trace_id,
+            'fee_type' => $info['is_pay'] == 1 ? 1 : 4,
+            'istry' => $istry,
+            'iscon' => 0,
+            'start_posi' => $start_posi
+        ];
+
+        $content = join(json_decode('"\u0001"', true), $content);
+
+        $filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.dat';
+        $check_filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.chk';
+
+        error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
+        error_log('', 3, './dashuju/' . $check_filename);
+        $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userplaydata.finish';
+        error_log('', 3, './dashuju/' . $finish_filename);
+
+        $this->success('');
+    }
+
+    //获取特殊机型
+    public function special_models() {
+        $special_models = config('site.special_models');
+        $special_models = explode(',', $special_models);
+
+        $this->success('获取特殊机型', $special_models);
+    }
+
+    //前端报错记录
+    public function app_error() {
+        $this->success('');
+    }
 
     /** * * @param string $string 需要加密的字符串 * @param string $key 密钥 * @return string */
     private function encrypt($string, $key) {