2

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

[画像] などの個々の配列要素にアクセスするにはどうすればよいですか

$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 に答える