__construct() public method

Method to create a JSON feed object
public __construct ( mixed $options, integer $limit ) : Json
$options mixed
$limit integer
return Json
Example #1
0
 /**
  * Method to create a Facebook JSON feed object
  *
  * @param  mixed  $options
  * @param  int    $limit
  * @return \Pop\Feed\Format\Json\Facebook
  */
 public function __construct($options, $limit = 0)
 {
     // Attempt to get the correct URL to parse
     if (is_array($options)) {
         if (isset($options['name'])) {
             $jsonUrl = str_replace('[{name}]', $options['name'], $this->urls['name']);
             $json = json_decode(file_get_contents($jsonUrl), true);
             $this->url = str_replace('[{id}]', $json['id'], $this->urls['id']);
             foreach ($json as $key => $value) {
                 $this->feed[$key] = $value;
             }
             $this->id = $json['id'];
         } else {
             if (isset($options['id'])) {
                 $this->url = str_replace('[{id}]', $options['id'], $this->urls['id']);
                 $this->id = $options['id'];
             } else {
                 if (isset($options['source'])) {
                     $json = json_decode($options['source'], true);
                     $this->url = str_replace('[{id}]', $json['id'], $this->urls['id']);
                     foreach ($json as $key => $value) {
                         $this->feed[$key] = $value;
                     }
                     $this->id = $json['id'];
                 }
             }
         }
     }
     parent::__construct($options, $limit);
 }
Example #2
0
 /**
  * Method to create a Youtube JSON feed object
  *
  * @param  mixed  $options
  * @param  int    $limit
  * @return \Pop\Feed\Format\Json\Youtube
  */
 public function __construct($options, $limit = 0)
 {
     // Attempt to get the correct URL to parse
     if (is_array($options)) {
         if (isset($options['name'])) {
             $this->url = str_replace('[{name}]', $options['name'], $this->urls['name']);
         } else {
             if (isset($options['id'])) {
                 $this->url = str_replace('[{id}]', $options['id'], $this->urls['id']);
             }
         }
     }
     parent::__construct($options, $limit);
 }