PHP 微博 发送 查看红包列表

2023-05-16

<?
//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&notify_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&notify_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;
    }
}


?>

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PHP 微博 发送 查看红包列表 的相关文章

  • 按某些字段排序的迭代学说集合

    我需要这样的东西 products Products getTable gt find 274 foreach products gt Categories gt orderBy title as category echo categor
  • Disqus API 创建帖子错误

    我在使用 Disqus API 尝试对 tumblr 中发布的出版物发表评论时遇到问题 这是代码
  • PHP内部hashCode函数

    我正在寻找与 JAVA 等效的 PHP SomeString hashCode 功能 我正在寻找的 hashCode 应该与 PHP 中用于索引 Hashmap 的 hashCode 相同 我希望你可以帮助我 EDIT 好的 找到了我正在搜
  • PHP OCI8 扩展不适用于 PHP 7 64 位

    我已经安装了 APACHE 2 4 x64 和 PHP7 x64 并下载了 PHP OCI 64 位库 但问题是每当我从 cli 运行 PHP 脚本时 它都会说 PHP启动 无法加载动态库 E 软件 服务器 php 7 0 11 Win32
  • “key”是MySqli中的保留字吗?我收到错误

    我刚刚真正接触 MySql MySqli 并且正在使用准备好的语句 除了这一行之外 我的整个脚本运行良好 if stmt con gt prepare SELECT bandHash userHash userPassHash type F
  • 带下拉列表的过滤器 Laravel

    我有一个下拉菜单 用于按类别过滤图像 我的第一个问题是我希望在过滤器之后选择选定的选项 我该怎么做 这是我第一次使用 Laravel 我想知道我的解决方案是否朝着正确的方向前进 现在我在两个函数中有相同的代码 我计划修复这个问题 但我真的无
  • Mysql正则表达式搜索不包含重复字符

    我有一个数据库表 其中包含字典中的单词 现在我想选择字谜词 例如 如果我给出字符串SEPIAN它应该获取像这样的值apes pain pains pies pines sepia etc 为此 我使用了查询 SELECT FROM word
  • php 的睡眠函数

    作为使用 cron 作业的可能替代方案 我找到了 sleep 函数 我以前从未使用过这个 如果我告诉我的脚本在一种循环内运行 并且在该循环内我有这样的指令 sleeps for 86400 seconds or one day sleep
  • 如何使用 PHP 读写编辑 pptx/docx/xlsx 文件?

    是否有库扩展可用于使用 PHP 有效处理 pptx docx xlsx 文件 到目前为止 我对 PPTX 文件更感兴趣 据我所知 这些文件格式 docx xlsx pptx 只是 zip 文件 它们属于 Office Open XML OO
  • “致命错误:调用未定义的函数 socket_create()”,即使在 php.ini 中启用

    我有一个奇怪的 PHP 问题 我在 Windows 7 的 IIS 上运行 PHP 5 当我在 PHP 文件中调用 socket create 时 如下所示 sock socket create AF INET SOCK DGRAM get
  • PCRE 库版本太旧

    Bug Genie 3 需要 PCRE 库 8 0 或更高版本 你有 版本 7 8 2008 09 05 将您的系统更新到最新版本 你常用的来源 在我查看问题并尝试通过以下步骤更新我的 PCRE 库后 wget the latest sou
  • 什么是好的、免费的 PHP 图表套件?

    我要做的只是基本的折线图 任何人分享的经验将不胜感激 不是真正的 PHP 但我发现 amchart 非常容易实现 而且看起来很棒 http www amcharts com http www amcharts com 还可以查看 Googl
  • Ionic 3 Uncaught(承诺):[object Object]

    我是 Ionic 3 和移动开发的新手 我正在尝试将 MySQL DB 连接到我的 Ionic 应用程序和 PHP Restful API 我用 Postman 测试了 API 它工作得很好 为了在 Ionic 中实现它 我做了以下操作 我
  • 通过php在csv单元格中创建回车符

    我正在尝试动态生成一个 csv 文件 其中包含一些包含多行的单元格 例如 地址字段需要分组为单个 地址 单元格 而不是地址 城市 州等 一切进展顺利 但在过去的两天里 我尝试在代码中插入 r r n n chr 10 chr 13 以及回车
  • Laravel:如何模拟依赖注入类方法

    我正在使用GitHub API https github com KnpLabs php github api通过一个Laravel API 包装器 https github com GrahamCampbell Laravel GitHu
  • 如何接收在 PHP 中使用“application/octet-stream”发送的 POST 数据?

    这就是我正在处理的事情 我们的一个计划有一个支持表格 用户可以使用它来请求支持 此表单的作用是 它向 PHP 脚本执行 HTTP POST 请求 该脚本应该收集信息并将其转发到支持电子邮件地址 POST 请求包含三个类型的文本字段Conte
  • 在 PHP 中将数组转换为字符串并将其恢复为数组

    我正在使用 Serialize 函数将数组存储在我的 MYSQL 数据库中 然后我在其他页面中取消序列化他 数组结构如下所示 Array 0 gt Array names gt somename1 rating gt 10 1 gt Arr
  • 如何使用 php 将文本区域中的链接转换为链接元素?

    我正在创建一个脚本 它包含一个发布脚本 但我希望用户直接从其他任何地方复制链接 当他们发布链接文本时 链接文本应自动将链接转换为链接元素 a 例如 Ask this on http stackoverflow com now 成为 Ask
  • 获取 png 图像的像素的 alpha 值?

    我正在使用以下代码 img imagecreatefrompng image png col imagecolorat img x y alpha col gt gt 24 0x7F 但 alpha 值始终为 127 即使像素位于 x y
  • 更新 Laravel 路由文件没有效果

    我正在尝试创建一个视图来显示数据库中的数据 但我发现我的路线文件不再执行任何操作 目前我正在尝试让测试功能正常工作 但是当我去 test它只是说 找不到网页 其他路线有效 即使我删除所有内容并保存文件 所有其他路线都可以工作 我努力了art

随机推荐