zoukankan      html  css  js  c++  java
  • 织梦熊掌号主动推送(实时)

    本推送是依据php的熊掌号主动推送,我们只需把下面的代码复制进文本,再把文本后缀改成.php上传至网站根目录,每次我们更新完文章之后,访问以下这个文件就可以了,这里我用我的网站进行举列:我们可以这样访问http://www.hfxskyyj.com/文件名.php/

    <?php
    require_once ("include/common.inc.php");
    require_once "include/arc.partview.class.php";
    require_once('include/charset.func.php');
    $year = date("Y");
    $month = date("m");
    $day = date("d");
    $dayBegin = mktime(0,0,0,$month,$day,$year);
    $dayEnd = mktime(23,59,59,$month,$day,$year);
    $query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin."";
    //echo $query;
    $urls="";
    $dsql->Execute('arch.id,types.typedir',$query);
    while($row = $dsql->GetArray('arch.id,types.typedir'))
    {
    $urls.="http://www.hfxskyyj.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; // 前边网址换成自己的
    }
    $urls=substr($urls,0,-1);
    $urls = explode(",",$urls);
    $api = 'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=熊掌号密钥&type=realtime'; // 前边的熊掌号ID和密钥换成自己的
    $ch = curl_init();
    $options = array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode(" ", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
    );
    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    echo $result;
    ?>

  • 相关阅读:
    Xpath定位总结
    robotframework运行时后台报错UnicodeDecodeError
    Selenium驱动Microsoft Edge浏览器(基于robotframework框架)的方法
    robotframework自动化测试安装配置
    硬币
    矩阵乘法
    动态规划和凸性优化
    动态规划背包问题--做题小总结
    CSAPP实验attacklab
    信息学奥赛出局?教育部:若提出申请,会认真研究
  • 原文地址:https://www.cnblogs.com/zqw111/p/10918977.html
Copyright © 2011-2022 走看看