sokil/php-social-opengraph
最新稳定版本:1.0.1
Composer 安装命令:
composer require sokil/php-social-opengraph
包简介
lib to work with OpenGraph
关键字:
README 文档
README
Lib to render open graph.
Installation
composer require sokil/php-social-opengraph
Basic Usage
// Open Graph $openGraph = new \Sokil\OpenGraph; $openGraph ->setTitle('The Matrix Revolutions') ->setDescription('The human city of Zion ...') ->setType(\Sokil\OpenGraph::TYPE_PRODUCTS_MOVIE) ->setImage('https://server.com/Matrix_Revolutions_poster.jpg') ->setUrl('http://www.imdb.com/title/tt0242653/') ->setVideoUrl('https://server.com/3453245.torrent') ->setVideoType('application/x-bittorrent');
Then you can get opengraph as array. This may be useful to render meta tags in frameworks. Example for Yii:
$cs = Yii::app()->getClientScript(); foreach($openGraph->toArray() as $property => $content) { $cs->registerMetaTag($content, null, null, array( 'property' => $property, )); }
You can render meta tags directly:
echo $openGraph->render(); // or just: echo $openGraph;
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-18