2016-05-23 46 views

回答

0

我發現用歐芹的方式:這個工作對我來說

/* 
    Function to return latest post, which are retrived from Parse.ly's API 
*/ 
    public static function get_most_viewed_homepage_articles ($limit=6) { 
     $attr= array('apikey' => "YOUR_API_KEY", 
       "secret" => "YOUR_API_SECRET", 
       "page" => "1", 
       "limit" => "$limit", 
       "time" =>"5m"); 
     $url="https://api.parsely.com/v2/realtime/posts"; 
     $url.="?"; 
     reset($attr); 
     while(list($attr_key, $attr_val) = each($attr)){$url.=$attr_key."=".$attr_val."&";} 
     $result = @file_get_contents($url); 
     $result_json = json_decode($result, true);  
     return $result_json;   
    } 

。我用它在function.php