分类目录归档:工作

thinkphp框架种使用overtrue/socialite

使用过程中会出现session冲突的问题:

自定义使用thinkphp的session验证

 $this->socialite = new SocialiteManager($config);
$state = sha1(uniqid(mt_rand(1, 1000000), true));
Session('state',$state);
return  $this->socialite->driver('qq')->stateless()->with(['state'=>$state])->redirect();

callback验证:

$user = $this->socialite->driver('qq')->stateless()->user();
$_state = $this->request->param('state');
$state = Session('state');
if(md5($state)!=md5($_state)){
     $this->error('非法来源');
}

php把html转word处理排版问题

html转word可以原样输出,用css控制排版布局,输出的内容可以是一个完整的html页面

echo $content;
ob_start();
header("Content-type: application/vnd.ms-word");
header("Accept-Ranges: bytes");
header("Accept-Length: ".strlen($content));
header('Content-Disposition: attachment; filename=filename.doc');
header("Pragma:no-cache");
header("Expires:0");
ob_end_clean();
exit(0);

后续:将html转换成pdf:

wkhtmltopdf在linux安装,需要安装中文字体