367 lines
12 KiB
PHP
367 lines
12 KiB
PHP
<?php
|
||
/**
|
||
* 伽莱网络开放平台 SDK
|
||
* @version 1.6.1 发布日期:2023-02-08 17:30
|
||
* @copyright 2023 ip6b.com
|
||
* APPID:49330ae23dad78f9
|
||
*APPKEY:ddb4311a227fb118cacd63cc68416ab5
|
||
*
|
||
*/
|
||
namespace extend\jinyouapi;
|
||
/**
|
||
* 通信编码协定 UTF-8
|
||
*/
|
||
|
||
class jinyou{
|
||
private static $ServerUrl="https://www.ip6b.com/openapi/";
|
||
/**
|
||
* 通信方法
|
||
*/
|
||
private static function send_post($method, $post_data)
|
||
{
|
||
$post_data=self::signAct($post_data);
|
||
$ch = curl_init();
|
||
curl_setopt($ch, CURLOPT_URL, self::$ServerUrl.$method);
|
||
curl_setopt($ch, CURLOPT_POST, 1);
|
||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||
$response= curl_exec($ch);
|
||
curl_close($ch);
|
||
return $response;
|
||
}
|
||
/**
|
||
* key排序签名
|
||
*/
|
||
private static function signAct($body)
|
||
{
|
||
$authStr="";
|
||
$body["st"]=time();
|
||
$body["appid"]="49330ae23dad78f9";
|
||
ksort($body);
|
||
foreach ($body as $item)
|
||
{
|
||
if(!is_object($item))
|
||
$authStr=$authStr.$item;
|
||
}
|
||
|
||
$body["sign"]=md5(md5($authStr)."ddb4311a227fb118cacd63cc68416ab5");
|
||
return $body;
|
||
}
|
||
/**
|
||
* 获取当前账户的可用余额
|
||
* @return @json
|
||
*/
|
||
public static function getMyPoint()
|
||
{
|
||
$res=self::send_post('Get_MyPoint', []);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* 获取所有动态服务器列表
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicLine($type=3)
|
||
{
|
||
$post_data = array(
|
||
'type'=>$type,
|
||
);
|
||
$res=self::send_post('Get_Dynamic_Line',$post_data);
|
||
return json_decode($res);
|
||
}
|
||
|
||
/**
|
||
* * 获取动态用户列表
|
||
* @param $page *当前分页
|
||
* @param $page_count *分页条目数 1-100
|
||
* @param $t_id @接入方客户唯一值UID用于查询客户账号列表、0或缺省则查询当前应用下全部客户账号,非必填字段
|
||
* @param $user @根据账号名称查询账号信息,非必填字段
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicAccount($page,$page_count,$t_id=0,$user="")
|
||
{
|
||
$post_data = array(
|
||
't_id'=>$t_id,
|
||
'user'=>$user,
|
||
'page'=>$page,
|
||
'page_count'=>$page_count,
|
||
);
|
||
$res=self::send_post('Get_Dynamic_Account', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
|
||
/**
|
||
* * 创建动态账号
|
||
* @param $width *订购带宽 1-20 单位 Mbps
|
||
* @param $meal *订购套餐 1-5 分别为 天卡、周卡、月卡、季卡、年卡,31为2小时测试卡,每个用户只允许开通一次
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @param $password *拨号密码 6-20位字符串
|
||
* @param $conn_max *连接数(同账号可以在不同服务器中同时在线的数量)1-100
|
||
* @param $t_id *接入方平台注册用户的唯一值,用于绑定客户账号
|
||
* @return @json
|
||
*/
|
||
public static function createDynamic($width,$meal,$account,$password,$conn_max,$t_id)
|
||
{
|
||
$post_data = array(
|
||
'width'=>$width,
|
||
'combos'=>$meal,
|
||
'account'=>$account,
|
||
'password'=>$password,
|
||
'conn_max'=>$conn_max,
|
||
't_id'=>$t_id,
|
||
);
|
||
$res=self::send_post('Create_Dynamic', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 创建平台第三方接入账号
|
||
* @param $phone *接入方平台用户注册手机号 同应用下手机号码不可重复
|
||
* @param $cn_name *用户实名认证后的真实姓名
|
||
* @param $cn_id *用户实名认证后的身份证号码
|
||
* @param $t_id *接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
|
||
* @return @json
|
||
*/
|
||
public static function createUsers($phone,$cn_name,$cn_id,$t_id)
|
||
{
|
||
$post_data = array(
|
||
'phone'=>$phone,
|
||
'cn_name'=>$cn_name,
|
||
'cn_id'=>$cn_id,
|
||
't_id'=>$t_id,
|
||
);
|
||
$res=self::send_post('Create_Users', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
|
||
/**
|
||
* * 获取代理商基础定价
|
||
* @param $width *订购带宽 1-20 单位 Mbps
|
||
* @param $meal *订购套餐 1-5 分别为 天卡、周卡、月卡、季卡、年卡
|
||
* @param $conn_max *连接数(同账号可以在不同服务器中同时在线的数量)1-100
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicPoint($width,$meal,$conn_max)
|
||
{
|
||
$post_data = array(
|
||
'width'=>$width,
|
||
'combos'=>$meal,
|
||
'conn_max'=>$conn_max,
|
||
);
|
||
$res=self::send_post('Get_Dynamic_Point', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 续费动态账号
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @param $meal *订购套餐 1-5 分别为 天卡、周卡、月卡、季卡、年卡
|
||
* @return @json
|
||
*/
|
||
public static function reNewDynamic($account,$meal)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
'combos'=>$meal,
|
||
);
|
||
$res=self::send_post('Renew_Dynamic', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 修改动态账户密码
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @param $password *新密码 6-20位字符串
|
||
* @return @json
|
||
*/
|
||
public static function reSetDynamicPassword($account,$password)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
'password'=>$password,
|
||
);
|
||
$res=self::send_post('Reset_Password_Dynamic', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 获取动态服务器完整列表
|
||
* @param $page *当前分页
|
||
* @param $page_count *分页条目数 1-100
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicOnline($account,$page,$page_count)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
'page'=>$page,
|
||
'page_count'=>$page_count,
|
||
);
|
||
$res=self::send_post('Get_Dynamic_Online', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 针对动态在线用户踢出下线
|
||
* @param $sid *sid参数即为{getDynamicOnline}函数锁返回的在线ID,应为32位字符串。
|
||
* @return @json
|
||
*/
|
||
public static function kickOffDynamicLine($sid)
|
||
{
|
||
$post_data = array(
|
||
'sid'=>$sid,
|
||
);
|
||
$res=self::send_post('Kick_Off_Dynamic_Line', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 设置动态账号防火墙状态
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @param $status *防火墙状态:0关闭、1开启。
|
||
* @return @json
|
||
*/
|
||
public static function setDynamicFirewallStatus($account,$status)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
'status'=>$status,
|
||
);
|
||
$res=self::send_post('Set_Dynamic_Firewall_Status', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 上传用户手持身份证照片
|
||
* @param $t_id *接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
|
||
* @param $upload_img *上传图片文件,格式要求jpg格式,文件小于1MB。
|
||
* @return @json
|
||
*/
|
||
public static function uploadExamine($t_id,$upload_img)
|
||
{
|
||
$post_data = array(
|
||
't_id'=>$t_id,
|
||
'upload_img'=>new \CURLFile($upload_img->getRealPath(),$upload_img->getOriginalMime(),$upload_img->getOriginalName()),
|
||
);
|
||
$res=self::send_post('Upload_Examine', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 上传用户手持身份证照片
|
||
* @param $t_id *接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
|
||
* @param $upload_imgurl *本地图片URL,格式要求jpg格式,文件小于1MB。
|
||
* @return @json
|
||
*/
|
||
public static function uploadExamineFile($t_id,$upload_imgurl)
|
||
{
|
||
$post_data = array(
|
||
't_id'=>$t_id,
|
||
'upload_img'=>new \CURLFile($upload_imgurl,mime_content_type($upload_imgurl),basename($upload_imgurl)),
|
||
);
|
||
$res=self::send_post('Upload_Examine', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
public static function uploadExaminePrepare($t_id,$upload_imgurl)
|
||
{
|
||
$post_data = array(
|
||
't_id'=>$t_id,
|
||
'upload_img'=>new \CURLFile($upload_imgurl,mime_content_type($upload_imgurl),basename($upload_imgurl)),
|
||
);
|
||
$res=self::send_post('Upload_Examine_Prepare', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 查询第三方接入用户状态
|
||
* @param $t_id *接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
|
||
* @return @json
|
||
*/
|
||
public static function examineStatus($t_id)
|
||
{
|
||
$post_data = array(
|
||
't_id'=>$t_id,
|
||
);
|
||
$res=self::send_post('Examine_Status', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 查询第三方接入用户状态
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @return @json
|
||
*/
|
||
public static function dynamicAccountExists($account)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
);
|
||
$res=self::send_post('Dynamic_Account_Exists', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 变更静态账户出口指向
|
||
* @param $account *拨号账号 6-20位字符串。
|
||
* @param $ename *出口服务器名 1-20位字符串。
|
||
* @param $pool *出口线路名 1-20位字符串。
|
||
* @return @json
|
||
*/
|
||
public static function editStaticOut($account,$ename,$pool)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
'ename'=>$ename,
|
||
'pool'=>$pool,
|
||
);
|
||
$res=self::send_post('Edit_Static_Out', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 获取指定城市的静态出口列表
|
||
* @param $city *城市ID
|
||
* @return @json
|
||
*/
|
||
public static function getStaticOut($city)
|
||
{
|
||
$post_data = array(
|
||
'city'=>$city,
|
||
);
|
||
$res=self::send_post('Get_Static_Out', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 获取独立定价账户下的产品列表
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicProduct()
|
||
{
|
||
$res=self::send_post('Get_Dynamic_Product', []);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 获取独立定价账户下的产品列表所对应的带宽套餐
|
||
* @return @json
|
||
*/
|
||
public static function getDynamicProductWidth($meal)
|
||
{
|
||
$post_data = array(
|
||
'meal'=>$meal,
|
||
);
|
||
$res=self::send_post('Get_Dynamic_Product_Width', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
public static function getaccount($meal)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$meal,
|
||
);
|
||
$res=self::send_post('Dynamic_Account_Exists', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
/**
|
||
* * 解除微信qq
|
||
* @return @json
|
||
*/
|
||
public static function openTxLimit($account)
|
||
{
|
||
$post_data = array(
|
||
'account'=>$account,
|
||
't_id'=>"121",
|
||
'fwstatus'=>0,
|
||
);
|
||
$res=self::send_post('Free_Firewall', $post_data);
|
||
return json_decode($res);
|
||
}
|
||
|
||
} |