2

使用https://github.com/scottmac/opengraph

如何访问单个数组元素,例如 [image]

$graph = OpenGraph::fetch('http://www.avessotv.com.br/bastidores-pantene-institute-experience-pg.html');
print_r($graph);

将返回

OpenGraph Object    
(
    [_values:OpenGraph:private] => Array
        (
            [type] => article
            [video] => http://www.avessotv.com.br/player/flowplayer/flowplayer-3.2.7.swf..
            [image] => /wp-content/thumbnails/9025.jpg
            [site_name] => Programa Avesso - Bastidores
            [title] => Bastidores “Pantene Institute Experience†P&G
            [url] => http://www.avessotv.com.br/bastidores-pantene-institute-experience-pg.html
            [description] => Confira os bastidores do Pantene Institute Experience, da Procter & Gamble. www.pantene.com.br Mais imagens:
        )

    [_position:OpenGraph:private] => 0
)
4

2 回答 2

2

简单到$graph->type$graph->video

从记录的来源:

  /**
   * Helper method to access attributes directly
   * Example:
   * $graph->title
   *
   * @param $key    Key to fetch from the lookup
   */
  public function __get($key){
于 2012-10-29T22:47:24.013 回答
2

这是PHP 魔法

利用$image_url = $graph->image;

于 2012-10-29T22:48:38.440 回答