mpalourdio / twitter-widgets
PHP 库,帮助渲染嵌入的 Twitter 时间线
0.2.0
2017-04-08 19:48 UTC
Requires
- php: ^7.0
- zendframework/zend-filter: ^2.3
- zendframework/zend-stdlib: ^2.3
Requires (Dev)
- phpunit/phpunit: ^6.1
- squizlabs/php_codesniffer: ^2.8
This package is not auto-updated.
Last update: 2024-09-28 16:41:29 UTC
README
TwitterWidgets
PHP 库,帮助渲染嵌入的 Twitter 时间线
要求
PHP 7.0+ - 仅支持 Composer 安装
安装
运行以下命令通过 Composer 安装
composer require mpalourdio/twitter-widgets
用法
$widgetOptions = new WidgetOptions($options); $userTimeline = new TimelineBuilder($widgetOptions); echo $userTimeline->renderWidget();
$options
可以处理以下参数: https://dev.twitter.com/web/embedded-timelines#options
它们在 $options
数组中作为数组键的 PHP 等价物使用
'class' => 'A css class, by default it will be twitter-timeline', 'href' => 'The link to the timeline', 'hrefText' => 'A title for your timeline to display', 'dataWidgetId' => 'Your data widget ID : must be a string (!)', 'dataTheme' => 'ex: dark', 'dataLinkColor' => 'ex: #cc0000', 'width' => 300 (integer), 'height' => 400 (integer), 'dataChrome' => 'noheader nofooter noborders noscrollbar transparent', => a string with options separated by a single space 'dataBorderColor' => 'border color used by the widget', 'language' => 'The widget language detected from the page, based on the HTML lang attribute of your content. You can also set the HTML lang attribute on the embed code itself.', 'dataTweetLimit' => 20, 'dataRelated' => 'benward,endform', 'dataAriaPolite' => 'polite or assertive',
TimelineBuilder#renderWidget() 方法接受一个布尔值来禁用添加到每个小部件中的 JavaScript 代码。如果您有多个小部件,这很有用,可以避免 JS 负载。
禁用时,要仅在您的 HTML 代码中添加一次所需的 JavaScript,请在 </body>
之前使用 OneTimeJsProvider#getOneTimeWidgetJs()
更多信息请见: https://dev.twitter.com/web/javascript/loading
ZF2
此处提供 ZF2 视图辅助工具: https://github.com/mpalourdio/zf2-twitter-widget
TWIG
此处提供 twig 扩展: https://github.com/mpalourdio/TwitterWidgetBundle