Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions MetaParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,31 @@ protected function _parseOpenGraphKeys()
preg_match_all('/([\'|"]{1})og:([a-zA-Z0-9\-:_]{1,25})\1/', $this->_body, $keys);
return array_pop($keys);
}

/**
* _parseTwitterCard
*
* @access protected
* @return array
*/
protected function _parseTwitterCard()
{
preg_match_all('/([\'|"]{1})twitter:([a-zA-Z0-9\-:_]{1,25})\1/', $this->_body, $keys);
return array_pop($keys);
}

/**
* _parseFacebookCard
*
* @access protected
* @return array
*/
protected function _parseFacebookCard()
{
preg_match_all('/([\'|"]{1})fb:([a-zA-Z0-9\-:_]{1,25})\1/', $this->_body, $keys);
return array_pop($keys);
}

/**
* _parseTitle
*
Expand Down Expand Up @@ -516,6 +540,8 @@ public function getDetails()
),
'images' => $this->getImages(),
'openGraph' => $this->getOpenGraph(),
'twitterCard' => $this->getTwitterCard(),
'facebookCard' => $this->getFacebookCard(),
'title' => $this->getTitle(),
'url' => $this->getUrl()
);
Expand Down Expand Up @@ -606,6 +632,40 @@ public function getOpenGraph()
}
return $graph;
}

/**
* getTwitterCard
*
* @access public
* @return array
*/
public function getTwitterCard()
{
$card = array();
$keys = $this->_parseTwitterCard();
foreach ($keys as $key) {
$card[$key] = $this->_parseMetaTag('twitter:' . ($key), 'property');
}

return $card;
}

/**
* getFacebookCard
*
* @access public
* @return array
*/
public function getFacebookCard()
{
$card = array();
$keys = $this->_parseFacebookCard();
foreach ($keys as $key) {
$card[$key] = $this->_parseMetaTag('fb:' . ($key), 'property');
}

return $card;
}

/**
* getTitle
Expand Down