emlog评论一键获取QQ昵称和头像的代码
首先在module.php里面加以下代码:
然后继续在module.php里面找到getGravatar($comment['mail'])这个替换成getqqtx($comment['mail'])一共有两个好像。反正都有的话就都换了
然后在你的发表评论那些代码里加上以下代码:
<?php //获取QQ信息
function getqqtx($qq){
$url="http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin=$qq&src_uin=qq.feixue.me&fid=blog&spec=100";
return $url;}
if(isset($_POST['qq'])){
$spurl = "http://r.pengyou.com/fcg-bin/cgi_get_portrait.fcg?uins={$_POST['qq']}";
$data = file_get_contents($spurl);
$nc=explode('"',$data);
$s=$nc[5];
$bm=mb_convert_encoding($s,'UTF-8','UTF-8,GBK,GB2312,BIG5');
if(empty($bm)){echo '<script>parent.document.getElementsByName("comname")[0].value = "QQ账号错误";parent.document.getElementsByName("commail")[0].value = "QQ账号错误";parent.document.getElementsByName("comurl")[0].value = "QQ账号错误";</script>';}
else{echo '<script>parent.document.getElementsByName("comname")[0].value = "'.$bm.'";parent.document.getElementsByName("commail")[0].value = "'.$_POST['qq'].'@qq.com";parent.document.getElementsByName("comurl")[0].value = "http://user.qzone.qq.com/'.$_POST['qq'].'";parent.document.getElementById("toux").src="http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin='.$_POST['qq'].'&src_uin=qq.feixue.me&fid=blog&spec=100";</script>';} }
function getqqxx($qq){
$ssud=explode("@",$qq,2);
if($ssud[1]=='qq.com'){
echo getqqtx($ssud[0]);
}else{
echo MyGravatar($qq);
}}
?>
<form action="" method="post" target="hiddenIframe">
<li>
<input placeholder="选填" value="" type="text" name="qq"/>
<label for="author"><i class="fa fa-qq"></i>QQ : </label>
<button type="submit" id="hqziliao">获取信息</button>
</li>
</form>
发表评论