Dcard API 蠻好運用的,不過使用限制沒有去確認 (執行次數 或 最大化數量)
直接拿來寫新的Dcard頁面似乎也不難 (?)
A. 取得文章 – https://www.dcard.tw/_api/posts/{PID}
B. 分類看板總覽 – https://www.dcard.tw/_api/forums/{category}/posts
GET變數:熱門文章 – popular=true、取得{PID起的文章} – before={PID}
function goGetiZO($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($ch); $GetDC = json_decode( $output ); for ( $j=0 ; $j<30 ; $j++ ) { $id=$GetDC[$j]->id; for ( $i=0 ; $i<10 ; $i++ ) { //每篇最多10張圖 $pic=$GetDC[$j]->media[$i]->url; if($pic==""){break;} echo "<a href='https://www.dcard.tw/f/{category}/p/".$id."'><img src='".$pic."' height='300px;'></a>"; } } }
因為單純想試試,所以Code的部分就沒有去做太多的調整囉 ( 欸