【问题标题】:Using Open Graph Protocol to extract og:image source使用 Open Graph Protocol 提取 og:image 源
【发布时间】:2012-10-29 22:44:34
【问题描述】:

使用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
)

【问题讨论】:

    标签: php regex github facebook-opengraph


    【解决方案1】:

    就像$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){
    

    【讨论】:

      【解决方案2】:

      这是PHP magic

      使用$image_url = $graph->image;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-04-19
        • 2013-06-22
        • 2020-12-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-06
        • 1970-01-01
        • 2012-10-26
        相关资源
        最近更新 更多