织梦熊掌号api自动提交 上传根目录即可
<p><span style="font-size:14px;">文件名1.php,可以放在网站根目录,到时候每天点一下就行了!只适用于自适应站点</span>
</p>
<ol class="linenums">
<li class="L0">
<span class="pun" style="font-size:14px;"><?</span><span class="pln" style="font-size:14px;">php</span>
</li>
<li class="L1">
<span class="pln" style="font-size:14px;">require_once </span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"include/common.inc.php"</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L2">
<span class="pln" style="font-size:14px;">require_once </span><span class="str" style="font-size:14px;">"include/arc.partview.class.php"</span><span class="pun" style="font-size:14px;">;</span>
</li>
<li class="L3">
<span class="pln" style="font-size:14px;">require_once</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">'include/charset.func.php'</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L4">
<span class="pln" style="font-size:14px;">$year </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> date</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"Y"</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L5">
<span class="pln" style="font-size:14px;">$month </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> date</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"m"</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L6">
<span class="pln" style="font-size:14px;">$day </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> date</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"d"</span><span class="pun" style="font-size:14px;">);</span>
</li>
</ol>
<p>
<br />
</p>
<ol class="linenums">
<li class="L7">
<span class="pln" style="font-size:14px;">$dayBegin </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> mktime</span><span class="pun" style="font-size:14px;">(</span><span class="lit" style="font-size:14px;">0</span><span class="pun" style="font-size:14px;">,</span><span class="lit" style="font-size:14px;">0</span><span class="pun" style="font-size:14px;">,</span><span class="lit" style="font-size:14px;">0</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$month</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$day</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$year</span><span class="pun" style="font-size:14px;">);</span>
</li>
</ol>
<p>
<br />
</p>
<p>
<br />
</p>
<ol class="linenums">
<li class="L8">
<span class="pln" style="font-size:14px;">$dayEnd </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> mktime</span><span class="pun" style="font-size:14px;">(</span><span class="lit" style="font-size:14px;">23</span><span class="pun" style="font-size:14px;">,</span><span class="lit" style="font-size:14px;">59</span><span class="pun" style="font-size:14px;">,</span><span class="lit" style="font-size:14px;">5</span><span class="lit" style="font-size:14px;">9</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$month</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$day</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$year</span><span class="pun" style="font-size:14px;">);</span>
</li>
</ol>
<p>
<br />
</p>
<ol class="linenums">
<li class="L9">
<span class="pln" style="font-size:14px;">$query </span><span class="pun" style="font-size:14px;">=</span><span class="pln"> </span><span class="str" style="font-size:14px;">"SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<"</span><span class="pun" style="font-size:14px;">.</span><span class="pln" style="font-size:14px;">$dayEnd</span><span class="pun" style="font-size:14px;">.</span><span class="str" style="font-size:14px;">" AND pubdate>"</span><span class="pun" style="font-size:14px;">.</span><span class="pln" style="font-size:14px;">$dayBegin</span><span class="pun" style="font-size:14px;">.</span><span class="str" style="font-size:14px;">""</span><span class="pun" style="font-size:14px;">;</span>
</li>
<li class="L0">
<span class="com" style="font-size:14px;">//echo $query;</span>
</li>
<li class="L1">
<span class="pln" style="font-size:14px;">$urls</span><span class="pun" style="font-size:14px;">=</span><span class="str" style="font-size:14px;">""</span><span class="pun" style="font-size:14px;">;</span><span class="pln"> </span>
</li>
<li class="L2">
<span class="pln" style="font-size:14px;">$dsql</span><span class="pun" style="font-size:14px;">-></span><span class="typ" style="font-size:14px;">Execute</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">'arch.id,types.typedir'</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$query</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L3">
<span class="kwd" style="font-size:14px;">while</span><span class="pun" style="font-size:14px;">(</span><span class="pln" style="font-size:14px;">$row </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> $dsql</span><span class="pun" style="font-size:14px;">-></span><span class="typ" style="font-size:14px;">GetArray</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">'arch.id,types.typedir'</span><span class="pun" style="font-size:14px;">))</span>
</li>
<li class="L4">
<span class="pun" style="font-size:14px;">{</span>
</li>
<li class="L5">
<span class="pln" style="font-size:14px;">$urls</span><span class="pun" style="font-size:14px;">.=</span><span class="str" style="font-size:14px;">"https://www.19tx.cn"</span><span class="pun" style="font-size:14px;">.</span><span class="pln" style="font-size:14px;">str_replace</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"{cmspath}"</span><span class="pun" style="font-size:14px;">,</span><span class="str" style="font-size:14px;">""</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$row</span><span class="pun" style="font-size:14px;">[</span><span class="str" style="font-size:14px;">'typedir'</span><span class="pun" style="font-size:14px;">]).</span><span class="str" style="font-size:14px;">"/"</span><span class="pun" style="font-size:14px;">.</span><span class="pln" style="font-size:14px;">$row</span><span class="pun" style="font-size:14px;">[</span><span class="pln" style="font-size:14px;">id</span><span class="pun" style="font-size:14px;">].</span><span class="str" style="font-size:14px;">".html"</span><span class="pun" style="font-size:14px;">.</span><span class="str" style="font-size:14px;">","</span><span class="pun" style="font-size:14px;">;</span><span class="pln"> </span>
</li>
<li class="L6">
<span class="pun" style="font-size:14px;">}</span>
</li>
<li class="L7">
<span class="pln" style="font-size:14px;">$urls</span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;">substr</span><span class="pun" style="font-size:14px;">(</span><span class="pln" style="font-size:14px;">$urls</span><span class="pun" style="font-size:14px;">,</span><span class="lit" style="font-size:14px;">0</span><span class="pun" style="font-size:14px;">,-</span><span class="lit" style="font-size:14px;">1</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L8">
<span class="pln" style="font-size:14px;">$urls </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> explode</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">","</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;">$urls</span><span class="pun" style="font-size:14px;">);</span>
</li>
</ol>
<p>
<br />
</p>
<p>
<br />
</p>
<ol class="linenums">
<li class="L9">
<span class="pln" style="font-size:14px;">$api </span><span class="pun" style="font-size:14px;">=</span><span class="pln"> </span><span class="str" style="font-size:14px;">'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=密钥&</span><span class="str" style="font-size:14px;">type=real</span><span class="str" style="font-size:14px;">time'</span><span class="pun" style="font-size:14px;">;</span><span class="pln"> </span><span class="com" style="font-size:14px;">// 前边的熊掌号ID和密钥换成自己的</span>
</li>
</ol>
<p>
<br />
</p>
<p>
<br />
</p>
<ol class="linenums">
<li class="L0">
<span class="pln" style="font-size:14px;">$ch </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> curl_init</span><span class="pun" style="font-size:14px;">();</span>
</li>
<li class="L1">
<span class="pln" style="font-size:14px;">$options </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> array</span><span class="pun" style="font-size:14px;">(</span>
</li>
<li class="L2">
<span class="pln" style="font-size:14px;"> CURLOPT_URL </span><span class="pun" style="font-size:14px;">=></span><span class="pln" style="font-size:14px;"> $api</span><span class="pun" style="font-size:14px;">,</span>
</li>
<li class="L3">
<span class="pln" style="font-size:14px;"> CURLOPT_POST </span><span class="pun" style="font-size:14px;">=></span><span class="pln"> </span><span class="kwd" style="font-size:14px;">true</span><span class="pun" style="font-size:14px;">,</span>
</li>
<li class="L4">
<span class="pln" style="font-size:14px;"> CURLOPT_RETURNTRANSFER </span><span class="pun" style="font-size:14px;">=></span><span class="pln"> </span><span class="kwd" style="font-size:14px;">true</span><span class="pun" style="font-size:14px;">,</span>
</li>
<li class="L5">
<span class="pln" style="font-size:14px;"> CURLOPT_POSTFIELDS </span><span class="pun" style="font-size:14px;">=></span><span class="pln" style="font-size:14px;"> implode</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">"\n"</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;"> $urls</span><span class="pun" style="font-size:14px;">),</span>
</li>
<li class="L6">
<span class="pln" style="font-size:14px;"> CURLOPT_HTTPHEADER </span><span class="pun" style="font-size:14px;">=></span><span class="pln" style="font-size:14px;"> array</span><span class="pun" style="font-size:14px;">(</span><span class="str" style="font-size:14px;">'Content-Type: text/plain'</span><span class="pun" style="font-size:14px;">),</span>
</li>
<li class="L7">
<span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L8">
<span class="pln" style="font-size:14px;">curl_setopt_array</span><span class="pun" style="font-size:14px;">(</span><span class="pln" style="font-size:14px;">$ch</span><span class="pun" style="font-size:14px;">,</span><span class="pln" style="font-size:14px;"> $options</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L9">
<span class="pln" style="font-size:14px;">$result </span><span class="pun" style="font-size:14px;">=</span><span class="pln" style="font-size:14px;"> curl_exec</span><span class="pun" style="font-size:14px;">(</span><span class="pln" style="font-size:14px;">$ch</span><span class="pun" style="font-size:14px;">);</span>
</li>
<li class="L0">
<span class="pln" style="font-size:14px;">echo $result</span><span class="pun" style="font-size:14px;">;</span>
</li>
<li class="L1">
<span class="pun" style="font-size:14px;">?></span>
</li>
</ol>
页:
[1]