私は、MetaData という特定のクラスですべてのメタ タグを取得する一種の Facebook リンク共有を作成しています。
コードは非常に単純です。
require_once('metadata.class.php');
$metaData = MetaData::fetch('http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.html');
// returns an associative array
var_dump($metaData->tags());
foreach ($metaData as $key => $value) {
echo "$key => $value";
}
今、それは各メタタグを返しますが、特定のタグを選択するとしたらどうすればよいですか?
たとえば、タイトル、説明、og 画像のみを取得したい。
$value['description'] で試しましたが、空の呼び出しが返されます。何かアイデアはありますか?
通常は次のようになります。
array(26) { ["title"]=> string(60) "Ken Robinson: How schools kill creativity | Video on TED.com" ["description"]=> string(149) "Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity." ["keywords"]=> string(63) "TED,Talks,children,creativity,culture,dance,education,parenting" ["medium"]=> string(5) "video" ["apple-itunes-app"]=> string(101) "app-id=376183339,app-argument=http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.html" ["robots"]=> string(13) "index, follow" ["og:title"]=> string(60) "Ken Robinson: How schools kill creativity | Video on TED.com" ["og:description"]=> string(149) "Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity." ["og:image"]=> string(48) "http://images.ted.com/images/ted/221_389x292.jpg" ["og:url"]=> string(71) "http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.html" ["og:type"]=> string(11) "video.other" ["video:tag"]=> array(8) { [0]=> string(3) "TED" [1]=> string(5) "Talks" [2]=> string(8) "children" [3]=> string(10) "creativity" [4]=> string(7) "culture" [5]=> string(5) "dance" [6]=> string(9) "education" [7]=> string(9) "parenting" } ["video:duration"]=> string(4) "1164" ["video:release_date"]=> string(10) "1151367060" ["twitter:card"]=> string(7) "summary" ["twitter:site"]=> string(9) "@tedtalks" ["twitter:title"]=> string(60) "Ken Robinson: How schools kill creativity | Video on TED.com" ["twitter:description"]=> string(149) "Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity." ["twitter:image:src"]=> string(48) "http://images.ted.com/images/ted/221_389x292.jpg" ["twitter:app:name:iphone"]=> string(9) "TED Talks" ["twitter:app:id:iphone"]=> string(9) "376183339" ["twitter:app:url:iphone"]=> string(71) "http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.html" ["twitter:app:name:ipad"]=> string(9) "TED Talks" ["twitter:app:id:ipad"]=> string(9) "376183339" ["twitter:app:url:ipad"]=> string(71) "http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.html" ["fb:app_id"]=> string(15) "201021956610141" } title => Ken Robinson: How schools kill creativity | Video on TED.comdescription => Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity.keywords => TED,Talks,children,creativity,culture,dance,education,parentingmedium => videoapple-itunes-app => app-id=376183339,app-argument=http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.htmlrobots => index, followog:title => Ken Robinson: How schools kill creativity | Video on TED.comog:description => Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity.og:image => http://images.ted.com/images/ted/221_389x292.jpgog:url => http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.htmlog:type => video.othervideo:tag => Arrayvideo:duration => 1164video:release_date => 1151367060twitter:card => summarytwitter:site => @tedtalkstwitter:title => Ken Robinson: How schools kill creativity | Video on TED.comtwitter:description => Sir Ken Robinson makes an entertaining and profoundly moving case for creating an education system that nurtures (rather than undermines) creativity.twitter:image:src => http://images.ted.com/images/ted/221_389x292.jpgtwitter:app:name:iphone => TED Talkstwitter:app:id:iphone => 376183339twitter:app:url:iphone => http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.htmltwitter:app:name:ipad => TED Talkstwitter:app:id:ipad => 376183339twitter:app:url:ipad => http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity.htmlfb:app_id => 201021956610141f
リンク クラス :メタデータ