<?
//aaaaweibohb.php
//发号token
$access_token = "_2A25yCAcuDeRhGeRG7lsU9i7Mwz2IHXVRRbNmrDV8PUJbitAKLU3dkWtNTYgvXJLp7-k6qcElVHTSYziJwT3Egmog";
//领取token
$access_token_GET = 'Cookie: SUB='."_2A25yCAWgDeRhGedJ61AT-SzMzj-IHXVRRbXorDV8PUJbitANLXTmkWtNVmHIxBVIKQELWC4klw2xFEgtqZM8YLkv";
require_once "aaaaweiboCode.php";
$money = isset($_REQUEST["money"]) ? $_REQUEST["money"] : "0.03"; //money
$greetings = isset($_REQUEST["greetings"]) ? $_REQUEST["greetings"] : "恭喜发财"; //greetings
$cmd = isset($_REQUEST["cmd"]) ? $_REQUEST["cmd"] : ""; //cmd
if($cmd == "send"){
create($money,$greetings);//创建订单
return;
}
$testText = "%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81";
// echo "$testText=".urldecode($testText);
$Retarr = hbList();//获取红包列表
foreach($Retarr as $value){
$set_id = $value["set_id"];
$amount = $value["amount"];
$blessing = $value["blessing"];
$openRet = $value["openRet"];
echo "ID={$set_id},amount={$amount},blessing={$blessing}<br>";
$yue = 0;
$uuid = $blessing;
$hb_id = $set_id;
if ($amount == "6.66") {
$yue = 1;
} else if ($amount == "12.01") {
$yue = 2;
}
if ($yue && $yue > 0 ) {
$noturl = "http://bcd3a487b3.320.io/Paybc/alipay_id_ini.php?cmd=add&uuid=$uuid&yue=$yue&tradeNo=$hb_id";
echo file_get_contents($noturl);
}
}
?>
<?php
//aaaaweiboCode.php
$fileName = "weoboHBiog/";//文件名称
is_dir($fileName) OR mkdir($fileName,0777,true);
$url = "https://pay.sc.weibo.com/api/merchant/pay/cashier?sign_type=RSA&sign=bGxMr7zyHyTyi4x80aSU8DaE7g4Yh8KRkg603zuOd07W0gwDk%2Fqo7G3rBX6AWC7GlNUs42tIoDDVwK5SKu2sPvSpH9TF7EnPqSKPGXGhFwOBLLJ7aCZNe2Onz1PIVt4Th4roFPZIC0U5iNBfW15K3VLgTpwRMYRE0JIsFqn1va4%3D&seller_id=5136362277&appkey=743219212&out_pay_id=6000079196652¬ify_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwnotify&return_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwreturn%3Fsinainternalbrowser%3Dtopnav&subject=%E5%BE%AE%E5%8D%9A%E7%BA%A2%E5%8C%85&body=&total_amount=100&cfg_follow_uid=5136362277&cfg_share_opt=0&cfg_follow_opt=0";
//创建订单
function create($money="",$blessing=""){
$blessing = urlencode($blessing);
$url = "https://mall.e.weibo.com/aj/redenvelope/create";
//bag_type=0 手气,bag_type=1 普通
$dat = "bag_type=0&puicode=&msgtype=0&msgid=0&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&amount=1.00&count=1&blessing=%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81&_t=0";
$dat = "bag_type=0&puicode=&msgtype=0&msgid=0&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&amount=$money&count=1&blessing=%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81&_t=0";
$dat = "bag_type=1&puicode=&msgtype=2&msgid=4526394552698990&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&singalAmount=$money&count=1&blessing=$blessing&amount=$money&_t=0";
$reText = HttppostTx($url,$dat);
// echo $reText;
$j = json_decode($reText);
$retcode = $j->code;
$retmsg = $j->msg;
$retUrl = $j->data->url;
if($retcode == 100000){
getWBpay($retUrl);
}else{
echo "001".$retmsg;
}
//{"code":"100000","msg":"\u64cd\u4f5c\u6210\u529f"
// echo $retUrl;
//https://pay.sc.weibo.com/api/merchant/pay/cashier?sign_type=RSA&sign=bGxMr7zyHyTyi4x80aSU8DaE7g4Yh8KRkg603zuOd07W0gwDk%2Fqo7G3rBX6AWC7GlNUs42tIoDDVwK5SKu2sPvSpH9TF7EnPqSKPGXGhFwOBLLJ7aCZNe2Onz1PIVt4Th4roFPZIC0U5iNBfW15K3VLgTpwRMYRE0JIsFqn1va4%3D&seller_id=5136362277&appkey=743219212&out_pay_id=6000079196652¬ify_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwnotify&return_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwreturn%3Fsinainternalbrowser%3Dtopnav&subject=%E5%BE%AE%E5%8D%9A%E7%BA%A2%E5%8C%85&body=&total_amount=100&cfg_follow_uid=5136362277&cfg_share_opt=0&cfg_follow_opt=0
}
//打开订单-获取-pay_params
function getWBpay($url){
$reText = HttppostTx($url,$dat);
//{"code":0,"msg":"","data":"sinaweibo://wbpay?entry=cashier&pay_params=xxx
// echo $reText;
$j = json_decode($reText);
$retcode = $j->code;
$retmsg = $j->msg;
$data = $j->data;
if($retcode."" == "0"){
$data = str_replace("sinaweibo://wbpay?entry=cashier&pay_params=","",$data);
buildparams($data);
}else{
echo "002".$retmsg;
}
//sinaweibo://wbpay?entry=cashier&pay_params=
// echo $data;
//{"code":0,"msg":"","data":"sinaweibo:\/\/wbpay?entry=cashier&pay_params=sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0"}
//sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0
// sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0
}
//获取连接
function buildparams($pay_params=""){
global $access_token;
prepare($pay_params);
$url = "https://pay.sc.weibo.com/api/client/opensdk/pay/buildparams";
$dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=sign_type%3Dmd5%26sign%3D6e7e7e87c0758057dbb5adc1be8ca6b4%26seller_id%3D5136362277%26out_pay_id%3D6000079194943%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
$dat = "uid=2859560081&gsid=$access_token&channel=ali_cashier&coupon_amount=0&request_str=$pay_params&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
// $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=$pay_params&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
// $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=sign_type%3Dmd5%26sign%3D4adfa9df216c9efc7e996ab5a707eb0a%26seller_id%3D5136362277%26out_pay_id%3D6000079197382%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
// echo $dat;
$reText = HttppostTx($url,$dat);
//{code: "100000", msg: "操作成功", data: {
$j = json_decode($reText);
$retcode = $j->code;
$retmsg = $j->msg;
$retsdk_data = $j->data->sdk_data;
if($retcode == 100000){
echo $retsdk_data;
}else{
echo "004".$retmsg;
}
// echo $reText;
}
//准备支付
function prepare($pay_params=""){
global $access_token;
$url = "https://pay.sc.weibo.com/api/client/opensdk/pay/prepare";
$dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&request_str=sign_type%3Dmd5%26sign%3D4adfa9df216c9efc7e996ab5a707eb0a%26seller_id%3D5136362277%26out_pay_id%3D6000079197382%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
$dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&request_str=$pay_params&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
$dat = "uid=2859560081&gsid=$access_token&request_str=$pay_params&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
HttppostTx($url,$dat);
//{"code":"100000","msg":"\u64cd\u4f5c\u6210\u529f","data":{"is_bind_alipay":1,"permit_sign":0,"total_amount":100,"balance":0,"balance_allowed":0,"method":[{"type":"ali_password","left_text":"","right_text":"","selected":0},{"type":"ali_cashier","left_text":"","right_text":"","selected":1}],"apple_card_type":2,"coupon_total_amount":0,"coupon_amount":0,"fold_count":0,"fold_text":""}}
}
//红包列表
function hbList(){
$url = "https://mall.e.weibo.com/h5/aj/redenvelope/redstaticlist";
$dat = "_t=0";
$reText = HttppostTx($url,$dat);
//{"code":"100000","msg":"操作成功","data":
$j = json_decode($reText);
$Retarr;
$retcode = $j->code;
$retmsg = $j->msg;
$ret_html = $j->data->html;
if($retcode == 100000){
// echo $ret_html;
//==========自己ID截取=========
//<a href="https://hongbao.weibo.cn/h5/hongbaolist?ouid=28xxxx081" sud
$ouid = substrText($ret_html,"https://hongbao.weibo.cn/h5/hongbaolist?ouid=",'" suda-uatrack');
echo "ID:" . $ouid . "<br>";
//=========红包ID截取==========
// <a href="https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=600xxx4&uicode=">
//hander
//<!-- 发出的红包 -->
//xxxxxxxxxxxxxx
//<!-- 发出的红包 -->
//end
$arrSendHB = explode("<!-- 发出的红包 -->",$ret_html);
if(count($arrSendHB) == 3){
$SendHBText = $arrSendHB[1];
}
//============金 额============
// <p class="amount">1.00元</p>
$arrAmount = explode('p class="amount"',$SendHBText);
// echo count($arrAmount). "<br>";
$arrSet_id = explode("mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=",$SendHBText);
$counSet_id = count($arrSet_id);
// echo $counSet_id;
for($i=1;$i<$counSet_id;++$i){
$value = "" . $arrSet_id[$i];
$set_id = substr($value,0,13);
$amount = substrText($arrAmount[$i] ,">" ,"元<");//>1.00元</p>.....
$fee = intval($amount*100);
// echo $amount;
// sendnotify($ouid, $set_id, $fee);
$openRet = draw($set_id);
$blessing = getHBinfo($set_id);
echo "ID=$set_id,金额=$amount,备注=$blessing,格式金额=$fee,打开=$openRet<br>";
$arrtp['set_id']=$set_id;
$arrtp['amount']=$amount;
$arrtp['blessing']=$blessing;
$arrtp['openRet']=$openRet;
$Retarr[] = $arrtp;
}
}else{
echo "hbList".$retmsg;
}
return $Retarr;
}
//获取红包备注信息
function getHBinfo($set_id=""){
global $fileName;
$hb_order_flie = $fileName . $set_id . "备注";
if(!$set_id || $set_id == ""){
return "ID nli";
}
if(file_exists($hb_order_flie)){
return file_get_contents($hb_order_flie);
}
$url = "https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=6000079387892&uicode=";
$url = "https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=$set_id&uicode=";
$reText = HttppostTx($url);
// <!-- 主人态红包详情 -->
if(strpos($reText,"主人态红包详情") > 0){
// <p class="blessing">恭喜发财666</p>
$blessing = substrText($reText,'<p class="blessing">','</p>');
xdd_file($hb_order_flie, $blessing);
return $blessing;
}
// echo $reText;
}
//打开红包
function draw($set_id=""){
global $access_token_GET;
$tptoken = $access_token_GET;
//领取红包号Cookie
// $tptoken = 'Cookie: SUB='."_2A25yCAWgDeRhGedJ61AT-SzMzj-IHXVRRbXorDV8PUJbitANLXTmkWtNVmHIxBVIKQELWC4klw2xFEgtqZM8YLkv";
global $fileName;
$hb_order_flie = $fileName . $set_id . "open";
if(!$set_id || $set_id == ""){
return "ID nli";
}
if(file_exists($hb_order_flie)){
return "ok";
}
sendmsg($set_id); //发送消息到聊天-否则没有权限
$url = "https://mall.e.weibo.com/h5/redenvelope/draw?set_id=6000079360793&sinainternalbrowser=topnav&portrait_only=1&from=10A2093010&weiboauthoruid=";
$url = "https://mall.e.weibo.com/h5/redenvelope/draw?set_id=$set_id&sinainternalbrowser=topnav&portrait_only=1&from=10A2093010&weiboauthoruid=";
$reText = HttppostTx($url,"",$tptoken);
// <!--红包开包页面-->
// <!--来晚了-->
if(strpos($reText,"红包开包页面") > 0){
xdd_file($hb_order_flie,"ok");
return "open ok";
}else if(strpos($reText,"--来晚了--") > 0){
$error_word = substrText($reText,'<p class="error_word">','</p>');
return "<br>ID=$set_id,".$error_word."<br>";
}else if(!$reText || $reText == ""){
// xdd_file($hb_order_flie,"ret nil");
return "ret nil";
}
else{
return $reText;
}
}
//发送消息到...
function sendmsg($set_id=""){
$url = "https://mall.e.weibo.com/aj/redenvelope/sendmsg";
$dat = "msgid=4526394552698990&msgtype=2&set_id=6000079200997&client_version=10.2.0&_t=0";
$dat = "msgid=4526394552698990&msgtype=2&set_id=$set_id&client_version=10.2.0&_t=0";
$reText = HttppostTx($url,$dat);
}
//发送通知--没用
// function sendnotify($uid="",$set_id="",$fee){
// $url = "https://mall.e.weibo.com/aj/redenvelope/sendnotify";
// // $dat = "uid=2859560081&set_id=6000079198644&bonus=73&_t=0";
// // $dat = "uid=$uid&set_id=$set_id&bonus=73&_t=0";
// $dat = "uid=$uid&set_id=$set_id&bonus=$fee&_t=0";
// $reText = HttppostTx($url,$dat);
// //{"code":"100000","msg":"操作成功"}
// $j = json_decode($reText);
// $retcode = $j->code;
// $retmsg = $j->msg;
// // $retsdk_data = $j->data->sdk_data;
// if($retcode == 100000){
// echo $retmsg;
// }else{
// echo "sendnotify".$retmsg;
// }
// }
function HttppostTx($url='', $post_data = '', $ContentType="a:a",$timeout = 5)
{
global $access_token;
// curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证证书
if ($post_data != '') {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POST, 1);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Requested-With: XMLHttpRequest',
'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Weibo (iPhone11,6__weibo__10.2.0__iphone__os12.3.1)',
// 'Cookie: SUB=',
'Cookie: SUB='.$access_token,
$ContentType,
));
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
function substrText($str="", $zText="", $yText=""){
// $result = strstr($tempText,'ticket=',1);//取前面
$result = $zText?strpos($str, $zText, 0):0;//位置
$resuly = $yText?strpos($str, $yText, $result):0;//文本,寻找文本,何处开始
$s1=$result+strlen($zText);
$s2=$resuly-$s1;
if(!$yText ){
$reText = substr($str, $s1 );
}else{
$reText = substr($str, $s1 , $s2);
}
return $reText;
}
function xdd_file($filename,$text=""){
try {
if(!$text || $text == ""){
if(file_exists($filename)){
return file_get_contents($filename);
}
return "";
}else{
return file_put_contents($filename, $text);
}
} catch (Exception $e) {
// return $e;
}
}
?>