QQ群一键强制加群API源代码

只需要群号实现一键加群,这个API是QQ官方的加群接口得到的,其中包含了三个接口,分别供PC和IOS端和安卓端调用实现加群和直接进群。

一键加群API接口PHP源代码:

<?php

$guin = @$_REQUEST['guin']; //接收群号
$type = @$_REQUEST['type']; //接收类型

if ($guin != '')
{
$url = 'http://shang.qq.com/wpa/g_wpa_get?guin='.$guin;
$data = get($url);
$key = GetBetween($data,'key":"','"}'); //取得key
$url = 'http://shang.qq.com/wpa/qunwpa?idkey='.$key;
$body = get($url); //取得跳转页面源码

if ($type != '')
{
if ($type == '1') //如果类型为1,取得PC端加群链接
{
$link = GetBetween($body,'var qsig = "','";'); //取得PC端加群链接
$link = str_replace('\u0026','&',$link);
//echo $link;
header('Location:'.$link); //重定向加群链接直接加群
}

if ($type == '2') //如果类型为2,取得移动端加群链接
{
$link = GetBetween($body,'var k = "','";');
$link = urldecode($link);
//echo $link;
header('Location:'.$link); //重定向加群链接直接加群
}

if ($type == '3') //如果类型为3,取得公用加群链接
{
//echo $url;
header('Location:'.$url); //重定向加群链接直接加群
}

}else{
//echo $body;
header('Location:'.$url);
}
}else{
echo '群号guin参数不正确';
}

function GetBetween($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}

function get($url)
{
$header = array (
"Content-Type: application/x-www-form-urlencoded",
'Accept: */*',
"Referer: ".$url,
'User-Agent: Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)',);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>

接口调用方式:

公用一键加群:https://api.mlwei.com/qun/?guin=779737370

PC端加群:https://api.mlwei.com/qun/?guin=779737370&type=1

移动端加群:https://api.mlwei.com/qun/?guin=779737370&type=2

公用加群链接:https://api.mlwei.com/qun/?guin=779737370&type=3

注:779737370是群号,后面的参数是类型。

THE END
本站内容均来源网络,并不代表本站观点,不对其真实合法性负责。如侵犯了您的权益,请附带网址告知,本站将立刻删除。
点赞6
分享