添加文章百度收录推送

2022-02-19 09:42:46 浏览数 (1)

cuteen主题目录下post.php文件

代码语言:javascript复制
</svg><?= $this->category == null ? "未分类" : $this->category(); ?></span>

的下面添加

代码语言:javascript复制
<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=https://www.roaing.com&token=sBLpxNhqkiXe8Y61';
        $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 '推送成功!';
             }
    ?>

也可以修改为点击推送

0 人点赞