<?php
function sign($data,$key){
return bin2hex(openssl_encrypt(json_encode($data),'AES-256-ECB',$key,OPENSSL_RAW_DATA,''));
}
function unsign($data,$key){
return openssl_decrypt(hex2bin($data),'AES-256-ECB', $key, OPENSSL_RAW_DATA, '');
}
function encrypt($data,$key){
return bin2hex(openssl_encrypt($data,'AES-256-ECB',$key,OPENSSL_RAW_DATA,''));
}
function base64EncodeImage($image_file){
$base64_image = '';
$image_info = getimagesize($image_file);
$image_data = fread(fopen($image_file, 'r'), filesize($image_file));
$base64_image = 'data:' . $image_info['mime'] . ';base64,' . (base64_encode($image_data));
$base64_image = ($base64_image);
return $base64_image;
}
#调用支付平台
$url = 'http://api.i.leadnew.com.cn/index.php';
//$url = 'http://api.leadnew.com.cn/index.php/centeruser/index';
$password = md5(md5('yl119692599'));//用户登录时候的密码
$token = '310282cd2e5b75cee221da18c9bce632';//有效时间7*24小时
#发短信
$post_datas = array(
'action'=>'user.sms',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'mobile'=>'13788326103',
'temp_code'=>'login-code',
'timestamp'=>time(),
),
);
#效验码
$post_data = array(
'action'=>'user.check.sms.code',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'mobile'=>'13788326103',
'temp_code'=>'login-code',
'code'=>'141822',
'timestamp'=>time(),
),
);
#获取用户信息
$post_datas = array(
'action'=>'user.info',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'uid'=>'753',
'timestamp'=>time(),
),
);
#通过openid获取用户
$post_datas = array(
'action'=>'other.user.login',
'type'=>'Web',
'identity_type'=>'wechat',
'identity'=>'openid',
'data'=>array(//data:需要加密的数据
'openid'=>'o2WBDuByuZofDUh_W8hCc5oOIsyQ',
'timestamp'=>time(),
),
);
#消息列表
$post_datas = array(
'action'=>'user.message',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'timestamp'=>time(),
),
);
#消息操作
$post_datas = array(
'action'=>'user.update.message',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'id'=>25,
//'read'=>1,
'dele'=>1,
'timestamp'=>time(),
),
);
#刷新token
$post_datas = array(
'action'=>'user.refresh.token',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'token'=>$token,//老token换取新token,超时就重登录
'timestamp'=>time(),
),
);
#修改密码
$post_datas = array(
'action'=>'user.update.password',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'password'=>'13788326103',
'timestamp'=>time(),
),
);
$avatar = base64EncodeImage("F:\\123.jpg");
#修改资料
$post_datas = array(
'action'=>'user.update.person',
'type'=>'Web',
'mobile'=>'13788326103',
'avatar'=>$avatar,
'data'=>array(//data:需要加密的数据;1.传空数据库参数不变,自动过滤掉空值参数
'avatar'=>substr($avatar,0,50),
'nickname'=>'LanYu3',//昵称
//'sex'=>1,//0:女,1:男
//'city'=>'桂林',//城市
//'province'=>'广西',//省份
//'country'=>'中国',//国家
'timestamp'=>time(),
),
);
#添加修改收货地址
$post_datas = array(
'action'=>'user.update.receive.address',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据;1.传空数据库参数不变,自动过滤掉空值参数
//'id'=>'177',//如果是修改填写数据id,添加不填
'name'=>'兰宇3',
'mobile'=>'13788326111',
'province'=>'广西',//省份
'city'=>'柳州',//城市
'area'=>'城中区',//区域
'address'=>'XX路XX区XX号',//详细地址
'province_id'=>'11',
'city_id'=>'113',
'area_id'=>'1227',
'default_address'=>'1',//默认收货地址
'timestamp'=>time(),
),
);
#删除修改收货地址
$post_datas = array(
'action'=>'user.delete.receive.address',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'id'=>'179',
'timestamp'=>time(),
),
);
#获取mall订单列表
$post_datas = array(
'action'=>'user.mall.order.list',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'page'=>1,
'rows'=>10,
'payment_status'=>'cancel',
'timestamp'=>time(),
),
);
#获取mall订单
$post_datas = array(
'action'=>'user.mall.order.info',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'order_id'=>'201905021603325271',
'timestamp'=>time(),
),
);
#mall订单支付
$post_datas = array(
'action'=>'user.mall.order.pay',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'order_id'=>'201907171629027710',
'timestamp'=>time(),
),
);
#获取mall订单物流
$post_datas = array(
'action'=>'user.mall.order.logistics.info',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'order_id'=>'201904122345526183',
'timestamp'=>time(),
),
);
#获取mall券码列表
$post_datas = array(
'action'=>'user.mall.ticket.list',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'page'=>1,
'rows'=>10,
//'status'=>'use',
'timestamp'=>time(),
),
);
#获取mall券码详情
$post_datas = array(
'action'=>'user.mall.ticket.info',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'key'=>'12944199',
'timestamp'=>time(),
),
);
#获取mall券码使用门店详情
$post_datas = array(
'action'=>'user.mall.ticket.use.shop.list',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'key'=>'12944199',
'timestamp'=>time(),
),
);
#绑定客户端
$post_datas = array(
'action'=>'user.bind.client',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'client_id'=>'11111111111',
'timestamp'=>time(),
),
);
#退出
$post_datas = array(
'action'=>'user.login.out',
'type'=>'Web',
'mobile'=>'13788326103',
'data'=>array(//data:需要加密的数据
'timestamp'=>time(),
),
);
switch($post_data['action']){
case 'user.sms':
case 'user.check.sms.code':
$key = md5('13788326103');
break;
case 'other.user.login':
$key = md5('wechatopenid');
break;
default:
$key = $token;
break;
}
$post_data['data'] = sign($post_data['data'],$key);
//初始化
$curl = curl_init();
//设置抓取的url
curl_setopt($curl, CURLOPT_URL, $url);
//设置头文件的信息作为数据流输出
curl_setopt($curl, CURLOPT_HEADER, 0);
//设置获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//设置post方式提交
curl_setopt($curl, CURLOPT_POST, 1);
//设置post数据
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
//执行命令
$response = curl_exec($curl);
//关闭URL请求
curl_close($curl);
print_r($response);print_r('<br>');
//显示获得的数据
$result = json_decode($response,true);
//print_r($result);print_r('<br>');
if(isset($result['data'])){
if($post_data['action'] == 'other.user.login')$key = md5('o2WBDuByuZofDUh_W8hCc5oOIsyQ');
$user = unsign($result['data'],$key);
$user = json_decode($user,true);
print_r($user);
//print_r(htmlspecialchars($user['pay_param']));
//print_r(urldecode($user['js_login']));
}