コード例 #1
0
ファイル: Reddit.php プロジェクト: judge2020/ChannelBot
 /**
  * Fetches and returns an array of the subreddits to which the logged-in user
  * is subscribed
  *
  * @access public
  * @return array
  */
 public function getMySubreddits()
 {
     if (!$this->isLoggedIn()) {
         $message = 'No user is logged in to list subreddit subscriptions';
         $code = RedditException::LOGIN_REQUIRED;
         throw new RedditException($message, $code);
     }
     $verb = 'GET';
     $url = 'http://www.reddit.com/reddits/mine.json';
     $response = $this->sendRequest($verb, $url);
     $subreddits = array();
     foreach ($response['data']['children'] as $child) {
         $subreddit = new Subreddit($this);
         $subreddit->setData($child['data']);
         $subreddits[] = $subreddit;
     }
     return $subreddits;
 }