[PHP] 纯文本查看 复制代码
<?php
$users = [
[自己的ID, 'AccessToken', '昵称区分'],
[自己的ID, 'AccessToken', '昵称区分']
];
$share_uid = 1111111; //被助力好友ID
$res = inviter($users, $share_uid);
$kturl = 'https://push.xuthus.cc/send/xxxxxx3689d5aa99dc431158b2'; //酷推
http($kturl, array(), 'c='.$res, 'POST');
function inviter($users, $id){
$url = 'https://mobile.yangkeduo.com/proxy/api/api/manor/friend/assist/water?pdduid=';
$data = '{"inviter_uid": "' . $id . '","fun_pl": 2}';
$msg = '';
foreach($users as $v){
$url = $url . $v[0];
$header = array('content-type: application/json;charset=UTF-8', 'accesstoken:' . $v[1]);
$res = http($url, $header, $data, 'POST');
$arr = json_decode($res, 1);
if($arr['success'] == 'true'){
$msg .= $v[2] . ":助力成功!";
}else{
$msg .= $v[2] . ":助力失败!";
}
}
sleep(1);
return $msg;
}
function http($url, $header, $data = '', $method = 'GET'){
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat');
curl_setopt ($curl, CURLOPT_REFERER, "https://servicewechat.com/wx32540bd863b27570/1278/page-frame.html");
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
if($method == 'POST'){
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
if ($data != ''){
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
curl_close($curl); // 关闭CURL会话
return $tmpInfo; // 返回数据
}