php - 使用Open Graph协议(protocol)提取og :image source

标签 php regex github facebook-opengraph

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

最佳答案

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

关于php - 使用Open Graph协议(protocol)提取og :image source,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13130733/

相关文章:

PHP MYSQL : 1st column as a header, 第二和第三列作为行

c# - 正则表达式解析字符串url链接

Git merge 冲突,但没有明显的区别

php - 通过(相似)名称查找文件 PHP

php - MySQL 'field list' 中的未知列

php日期格式正则表达式检查

Github 显示我的提交已被 2 位作者推送 : me and me

git - 将 Git 项目推送到本地目录

php - 如何在 MySQL 查询结果中查找特定行?

javascript - 如何验证 jquery 正则表达式?