2016-08-22 41 views
-2

我一直在嘗試從新的分享帖子中獲取數據,但是在你無法從超過100個帖子中獲取數據的情況下,任何人都可以幫助我geerver下面是我的代碼從100 reddit的帖子中獲取數據php

$output = ""; 
    for($digit=0; $digit<1000; $digit+=25){ 
     $jsondata = trim(file_get_contents("http://www.reddit.com/new/.json?count=$digit")); 

     $json = json_decode($jsondata, true); 

     $moviesChildren = $json['data']['children']; 
     foreach($moviesChildren as $movie){ 

      $output .= '"'.$movie["data"]["title"].'", '; 
      $output .= $movie["data"]["ups"].", "; 
      $output .= $movie["data"]["num_comments"].", "; 
      $output .= $movie["data"]["domain"]."\n\r"; 
      $output .= "<br />"; 

     } 

    } 
    echo $output; 
+0

任何人都可以幫助我! –

+0

是否有人在那裏? –

回答

0

什麼是你得到的輸出,你期待什麼,而不是?

首先,你會想follow the API rules about authentication否則你會很快被限制,並可能被禁止。

Listingsbeforeafter屬性來幫助分頁。您需要將這些傳遞到您的後續GET中才能獲取下一頁。