需求:用户扫码授权后自动转发视频到抖音,转发完成后获得一张优惠券,视频要随机生成(用阿里云视频生产接口提前后台生成好),因为同一个视频会被抖音降权
我用的yii2框架,具体写法需要自己改一改
1:接入抖音jssdk,实现抖音端扫码授权,具体接入步骤参考抖音给的文档
根据抖音给的文档接入,比较值得注意的是签名验证,下边附上签名验证的php代码
后台生成签名
//验证签名
public function actionGetSignature(){
\Yii::$app->response->format = Response::FORMAT_JSON;
$url = 'https://open.douyin.com/oauth/client_token/';
$params = [
'client_key' => 网站应用的clientkey,
'client_secret' => 网站应用的secret,
'grant_type' => 'client_credential'
];
$client_data = \Yii::$app->HttpHelper->curlPost($url,$params);//封装好的curl方法 post上传
$client_data = json_decode($client_data,true);
$client_acess_token = $client_data['data']['access_token'];
$jsapi_ticket_url = "https://open.douyin.com/js/getticket?access_token=".$client_acess_token;
$ticket_info = \Yii::$app->HttpHelper->curlGet($jsapi_ticket_url);//curl get方式上传
$ticket_info = json_decode($ticket_info,true);
$ticket = $ticket_info