|
|
@ -138,6 +138,9 @@ Class FrontApiController extends SiteController { |
|
|
|
if (!empty($tagName)) { |
|
|
|
if (!empty($tagName)) { |
|
|
|
$done = $done && $this->saveVideoToTag($shareUrl, $tagName); |
|
|
|
$done = $done && $this->saveVideoToTag($shareUrl, $tagName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//调用HeroUnion联盟接口,提交新的数据抓取任务 |
|
|
|
|
|
|
|
$this->addHeroUnionTask($shareUrl, $platform); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $done; |
|
|
|
return $done; |
|
|
@ -185,4 +188,83 @@ Class FrontApiController extends SiteController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function sign($params, $token) { //对参数做MD5签名 |
|
|
|
|
|
|
|
return md5( json_encode(ksort($params)) . $token ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提交视频抓取任务到HeroUnion英雄联盟 |
|
|
|
|
|
|
|
protected function addHeroUnionTask($shareUrl, $platform) { |
|
|
|
|
|
|
|
$heroUnionConfig = FSC::$app['config']['heroUnion']; |
|
|
|
|
|
|
|
$params = array( |
|
|
|
|
|
|
|
'uuid' => $heroUnionConfig['uuid'], |
|
|
|
|
|
|
|
'url' => $shareUrl, |
|
|
|
|
|
|
|
'platform' => $platform, |
|
|
|
|
|
|
|
'contract' => $heroUnionConfig['contract'], |
|
|
|
|
|
|
|
'data_mode' => $heroUnionConfig['contract'], |
|
|
|
|
|
|
|
'country' => $heroUnionConfig['contract'], |
|
|
|
|
|
|
|
'lang' => $heroUnionConfig['contract'], |
|
|
|
|
|
|
|
'notify_url' => $heroUnionConfig['notify_url'], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$params['sign'] = $this->sign($params, $heroUnionConfig['token']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$api = $heroUnionConfig['server_url'] . '/api/newtask/'; |
|
|
|
|
|
|
|
$res = this->request($api, $params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !empty($res) && $res['status'] == 200 ? $res['result'] : false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 保存快捷方式 |
|
|
|
|
|
|
|
protected function saveUrlShortCut($task_id, $task_url) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 保存描述文件 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 保存封面图 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: HeroUnion任务数据通知回传接口 |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* let params = { |
|
|
|
|
|
|
|
"task_id": task.id, |
|
|
|
|
|
|
|
"task_result": task.results, |
|
|
|
|
|
|
|
"timestamp": common.getTimestamp(), |
|
|
|
|
|
|
|
"sign": "" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
public function actionHuNotify() { |
|
|
|
|
|
|
|
$task_id = $this->post('task_id', ''); |
|
|
|
|
|
|
|
$task_result = $this->post('task_result', ''); |
|
|
|
|
|
|
|
$timestamp = $this->post('timestamp', ''); |
|
|
|
|
|
|
|
$sign = $this->post('sign', ''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$code = 1; |
|
|
|
|
|
|
|
$msg = ''; |
|
|
|
|
|
|
|
$err = ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//参数检查 |
|
|
|
|
|
|
|
if (empty($task_id) || empty($task_result) || empty($timestamp) || empty($sign)) { |
|
|
|
|
|
|
|
$code = 0; |
|
|
|
|
|
|
|
$err = '参数缺失!'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$heroUnionConfig = FSC::$app['config']['heroUnion']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证签名 |
|
|
|
|
|
|
|
if ($code == 1) { |
|
|
|
|
|
|
|
$checkParams = array( |
|
|
|
|
|
|
|
'task_id' => $task_id, |
|
|
|
|
|
|
|
'task_result' => $task_result, |
|
|
|
|
|
|
|
'timestamp' => $timestamp, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$mySign = $this->sign($checkParams, $heroUnionConfig['token']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strtolower($mySign) != strtolower($sign)) { |
|
|
|
|
|
|
|
$code = 0; |
|
|
|
|
|
|
|
$err = '签名验证不通过!'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo 'Done'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|