Pop\Feed\Format\Rss\Facebook::parse PHP Метод

parse() публичный Метод

Method to parse a Facebook RSS feed object
public parse ( ) : void
Результат void
    public function parse()
    {
        parent::parse();
        // If graph.facebook.com hasn't been parsed yet.
        if (!isset($this->feed['username'])) {
            $objItems = $this->obj->channel->item;
            $username = null;
            foreach ($objItems as $itm) {
                if (strpos($itm->link, '/posts/') !== false) {
                    $username = substr($itm->link, strpos($itm->link, 'http://www.facebook.com/') + 24);
                    $username = substr($username, 0, strpos($username, '/'));
                }
            }
            if (null !== $username) {
                $json = json_decode(file_get_contents('http://graph.facebook.com/' . $username), true);
                foreach ($json as $key => $value) {
                    $this->feed[$key] = $value;
                }
            } else {
                if (isset($this->options['name'])) {
                    $this->feed['username'] = $this->options['name'];
                }
            }
        }
        if (strpos($this->feed['url'], $this->feed['username']) === false) {
            $this->feed['url'] .= $this->feed['username'];
        }
        if (null === $this->feed['author']) {
            $this->feed['author'] = isset($this->obj->channel->item[0]->author) ? (string) $this->obj->channel->item[0]->author : $this->feed['username'];
        }
        if (null === $this->feed['date']) {
            $this->feed['date'] = (string) $this->obj->channel->lastBuildDate;
        }
        $items = $this->feed['items'];
        foreach ($items as $key => $item) {
            $items[$key]['title'] = str_replace(array('<![CDATA[', ']]>'), array(null, null), $item['title']);
            $items[$key]['content'] = str_replace(array('<![CDATA[', ']]>'), array(null, null), $item['content']);
        }
        $this->feed['items'] = $items;
    }