首页 各类教程 / 未收录,推送中

增加代码

在所用主题目录下post.php中找到</header>
在其上方添加

 <span style="margin-left:8px;"> / <span style="color:#E6A23C;" id="subtjj">未收录,推送中 
        </span></span>
        <script>
    function subtj(){
                       document.getElementById("subtjj").style.color="#67C23A";
                       $('#subtjj').text("<?php echo baidu_check(); ?>");
    }
    setTimeout("subtj()","2000");
</script>
<?php
    function baidu_check() {
        $pageURL = (@$_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
        $pageURL .= $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];     
        $urls = array(
            $pageURL
         );
        $api = 'http://data.zz.baidu.com/urls?site=xxx';//此为百度API,xxx为百度站长工具申请的域名及token,请自行替换
        $ch = curl_init();
        $options =  array(
            CURLOPT_URL => $api,
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => implode("n", $urls),
            CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
        );
        curl_setopt_array($ch, $options);
        $res=json_decode(curl_exec($ch),true);
        $ed = ($res['remain']);
        $cg = ($res['success']);
        return '推送成功!';
             }
    ?>

调用jquery库

若已调用可忽略以下部分
将其一并放入head.php中</head>之上

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>



文章评论

    访客ChromeAndroid
    2021-08-17 17:26   回复

    Good

      轮回 站长ChromeAndroid
      2021-09-1 22:44   回复

      哦耶