2024-12-22 17:41:42 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\channel\service\system;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 百度携号转网api
|
|
|
|
* Class Baidumnpapi
|
|
|
|
* @package app\channel\service
|
|
|
|
*/
|
|
|
|
class Baidumnpapi extends Core
|
|
|
|
{
|
|
|
|
# 这几个可以后台设置
|
|
|
|
protected $host = '';
|
|
|
|
protected $mid = '';
|
|
|
|
protected $token = '';
|
|
|
|
protected $method = '';
|
|
|
|
|
|
|
|
#通用充值
|
2024-12-23 13:50:52 +08:00
|
|
|
public function phone_mnp($param)
|
2024-12-22 17:41:42 +08:00
|
|
|
{
|
2024-12-23 13:50:52 +08:00
|
|
|
$mobile = $param['mobile'];
|
2024-12-22 17:41:42 +08:00
|
|
|
$url = $this->host .'?mobile='.$mobile;
|
|
|
|
$headers = [
|
|
|
|
'Content-Type'=>'application/json',
|
|
|
|
'X-Bce-Signature'=>'AppCode/'.$this->mid,
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->curl('post', $url, [] ,true,$headers);
|
2024-12-23 13:50:52 +08:00
|
|
|
// var_dump($response);die;
|
2024-12-22 17:41:42 +08:00
|
|
|
$response = $this->response($response);
|
|
|
|
//$response['data'] = '{}';
|
|
|
|
//$response['msg'] = 'ok';
|
2024-12-23 13:50:52 +08:00
|
|
|
$isp_array = [
|
|
|
|
'移动' =>1,
|
|
|
|
'联通'=>2,
|
|
|
|
'电信'=>3];
|
2024-12-22 17:41:42 +08:00
|
|
|
if($response['msg'] == 'ok'){
|
|
|
|
if(isset($response['array']['result']['Now_isp'])){
|
2024-12-23 13:50:52 +08:00
|
|
|
return ['mobile'=>$response['array']['result']['Mobile'],'old_isp'=>$isp_array[$response['array']['result']['Init_isp']],'new_isp'=>$isp_array[$response['array']['result']['Now_isp']] ];
|
|
|
|
|
2024-12-22 17:41:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $response['msg'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 数据响应格式处理
|
|
|
|
public function response($data)
|
|
|
|
{
|
|
|
|
$log['type'] = 'response';
|
|
|
|
$log['data'] = $data;
|
|
|
|
$log['config'] = $this->data;
|
|
|
|
$this->log($log);
|
|
|
|
|
|
|
|
$array = $this->json_decode($data);
|
|
|
|
if (!$array) {
|
|
|
|
$msg = 'error';
|
|
|
|
} elseif (isset($array['code']) && $array['code'] == 0) {
|
|
|
|
# 正确
|
|
|
|
$msg = 'ok';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
# 错误
|
|
|
|
$msg = isset($array['info']) ? $array['info'] : 'error';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return array
|
|
|
|
(
|
|
|
|
'msg' => $msg,
|
|
|
|
'data' => $data,
|
|
|
|
'array' => $array,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 查询余额接口
|
|
|
|
public function account($day)
|
|
|
|
{
|
|
|
|
// $request['day'] = $day;
|
|
|
|
// $request['appid'] = $this->mid;
|
|
|
|
// $request['version'] = 'v4';
|
|
|
|
// $request['product'] = 'query';
|
|
|
|
// list($msec, $sec) = explode(' ', microtime());
|
|
|
|
// $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
|
|
|
|
// $request['time'] = $msectime;
|
|
|
|
// $request['nonce'] = substr(sha1(microtime()), rand(10, 15));
|
|
|
|
// $request['sign'] = $this->_sign($request);
|
|
|
|
// $url = $this->host . 'handle/accountByDay';
|
|
|
|
// $response = $this->curl('post', $url, $request,true);
|
|
|
|
// $response = $this->response($response);
|
|
|
|
//
|
|
|
|
// return $response['array']['data'];
|
|
|
|
}
|
|
|
|
|
|
|
|
# 提交数据
|
|
|
|
private function submit($param, $check)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|