今天給大家分享dedecms織夢(mèng)怎么做熊掌號(hào)自動(dòng)提交方法,織夢(mèng)使用的是另外的一個(gè)二級(jí)目錄,所以在提交熊掌號(hào)的時(shí)候有點(diǎn)復(fù)雜!
第一步:在\plus\task目錄下新建一個(gè)php文件,命名為xzh.php代碼如下:
require_once(dirname(__FILE__).'/../../include/common.inc.php'); require_once(DEDEINC."/arc.partview.class.php"); require_once(dirname(__FILE__).'/../../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.="$urls.="http://mengdiqiu.com.cn".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";".","; } $urls=substr($urls,0,-1); $tjurl = $urls; $urls = explode(",",$urls); $api = 'http://data.zz.baidu.com/urls?appid=1567968668883362&token=TqR2soisGxVnnKiN&type=realtime'; // 熊掌號(hào)api接口調(diào)用地址 $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); $result = curl_exec($ch); echo $result; $dsql->ExecuteNoneQuery("Update `xiuzhanwang_sys_task` set sta='成功' where dourl='xzh.php' "); $jieguo = date('Y-m-d H:i:s',time())."返回結(jié)果:".$result."\r\n".$tjurl; $numbytes = file_put_contents('xzh.txt', $jieguo); //返回結(jié)果 exit(); |
第二步:在網(wǎng)站后臺(tái)系統(tǒng)-計(jì)劃任務(wù)管理里面新增一個(gè)任務(wù),運(yùn)行程序填xzh.php,設(shè)定好執(zhí)行規(guī)則。
第三步:在模板中用JS調(diào)用/plus/task.php?client=js任務(wù)執(zhí)行成功之后會(huì)在\plus\task目錄下生成一個(gè)xzh.txt文件,返回提交結(jié)果、任務(wù)執(zhí)行時(shí)間、提交的url,如下圖: