承接 jclyons52/page-preview 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jclyons52/page-preview

Composer 安装命令:

composer require jclyons52/page-preview

包简介

get info about page links and generate preview images

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Creates link previews to pages with thumbnail, title and description

demo

Install

Via Composer

$ composer require jclyons52/page-preview

Usage

$previewManager = PreviewManager::create();
$preview = $previewManager->fetch('https://somewebsite.com');
echo $preview->render(); // returns bootstrap media link preview
echo $preview->toJson(); // returns json string of preview attributes

or do it inline:

PreviewManager::create()->fetch('https://somewebsite.com')->render();

Use another one of the other default templates:

$previewManager->render('thumbnail');

define your own templates:

$previewManager->fetch('https://somewebsite.com')->render('myAwesomeTemplate', '/path/to/template/directory');

caching

Http calls are slow, so to speed up your response times you may want to cache your previews. This package can take any psr-6 compliant cache driver as a parameter.

$pool = new Pool();

$previewManager = PreviewManager::create($pool);

$preview = $previewManager->findOrFetch('http://www.example.com/directory');

$previewManager->cache($preview);

The data available for you templates will be:

  • string $title - meta title or page title if not found in meta
  • string $description - meta description
  • string $url - link url
  • array $images - array of image urls
  • array $meta - array of meta values with their names as keys

If you're usign information from tags such as the twitter meta tags (or anything seperated with ':') you may want to use the unFlatten function to get a multi level array.

This meta:

<meta name="twitter:card" content="app">
<meta name="twitter:site" content="@TwitterDev">
<meta name="twitter:description" content="Cannonball is the fun way to create and share stories and poems on your phone. Start with a beautiful image from the gallery, then choose words to complete the story and share it with friends.">
<meta name="twitter:app:country" content="US">
<meta name="twitter:app:name:iphone" content="Cannonball">
<meta name="twitter:app:id:iphone" content="929750075">
<meta name="twitter:app:url:iphone" content="cannonball://poem/5149e249222f9e600a7540ef">
<meta name="twitter:app:name:ipad" content="Cannonball">
<meta name="twitter:app:id:ipad" content="929750075">
<meta name="twitter:app:url:ipad" content="cannonball://poem/5149e249222f9e600a7540ef">
<meta name="twitter:app:name:googleplay" content="Cannonball">
<meta name="twitter:app:id:googleplay" content="io.fabric.samples.cannonball">
<meta name="twitter:app:url:googleplay" content="http://cannonball.fabric.io/poem/5149e249222f9e600a7540ef">

using unFlatten:

$meta = $preview->meta->unFlatten()['twitter'];

Would produce the following array:

[
    "card" => "app",
    "site" => "@TwitterDev",
    "description" => "Cannonball is the fun way to create and share stories and poems on your phone. Start with a beautiful image from the gallery, then choose words to complete the story and share it with friends.",
    "app" => [
        "country" => "US",
        "name" => [
            "iphone" => "Cannonball",
            "ipad" => "Cannonball",
            "googleplay" => "Cannonball",
        ],
        "id" => [
            "iphone" => "929750075",
            "ipad" => "929750075",
            "googleplay" => "io.fabric.samples.cannonball",
        ],
        "url" => [
            "iphone" => "cannonball://poem/5149e249222f9e600a7540ef",
            "ipad" => "cannonball://poem/5149e249222f9e600a7540ef",
            "googleplay" => "http://cannonball.fabric.io/poem/5149e249222f9e600a7540ef",
        ],
    ]

];

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email jclyons52@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 69
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固