htmlburger/carbon-twitter
Composer 安装命令:
composer require htmlburger/carbon-twitter
包简介
Helper library for retrieving information from the Twitter API.
关键字:
README 文档
README
Helper library for retrieving tweets from the Twitter API.
Installation
The library is available as Composer package. You can include it in your Project with:
composer require htmlburger/carbon-twitter
Usage
use Carbon_Twitter\Carbon_Twitter; Carbon_Twitter::config( array( 'api' => array( 'access_token' => '', 'access_token_secret' => '', 'consumer_key' => '', 'consumer_secret' => '', ), 'cache_lifetime' => 300, 'verbose' => false, 'cache_candidates' => [ 'WordPress', 'File' ], ) ); $tweets = Carbon_Twitter::get_tweets( 'wordpress', 5 ); foreach ( $tweets as $tweet ) { echo $tweet->text; }
or by using the helper functions:
carbon_twitter_set_config( array( 'api' => array( 'access_token' => '', 'access_token_secret' => '', 'consumer_key' => '', 'consumer_secret' => '', ), 'cache_lifetime' => 300, 'verbose' => false, 'cache_drivers' => [ 'WordPress', 'File' ], ) ); $tweets = carbon_twitter_get_tweets( 'wordpress', 5 ); foreach ( $tweets as $tweet ) { echo $tweet->text; }
Configuration Parameters
api (array) - required
The api parameter holds an array of 4 elements:
access_tokenaccess_token_secretconsumer_keyconsumer_secret
cache_lifetime (int) - optional
The cache duration defined in seconds. Defaults to 300 seconds (5 minutes)
verbose (boolean) - optional
Whether to enable Verbose mode. Defaults to false.
cache_drivers (array) - optional
An array of Cache Drivers to use. Uses the first Driver which is supported in the Project environment. Defaults to array( 'WordPress', 'File' )
In WordPress environment
Once the library is installed in your WordPress project, the receive the following features out of the box:
- Carbon_Twitter_Feed widget is being registered
- A new Carbon Container is registered - Twitter Settings
There are several hooks that you can use in order to customize the functionality
Carbon_Twitter_Feed_Widget
carbon_twitter_widget_id
Allows you to modify the Widget ID.
apply_filters( 'carbon_twitter_widget_id', 'carbon_twitter_feed_widget' );
carbon_twitter_widget_title
Allows you to modify the default Widget title.
apply_filters( 'carbon_twitter_widget_title', __( 'Carbon Twitter Feed', 'carbon-twitter' ) )
carbon_twitter_widget_description
Allows you to modify the default Widget description.
apply_filters( 'carbon_twitter_widget_description', __( 'Displays a Twitter Feed.', 'carbon-twitter' ) )
carbon_twitter_widget_fields
Allows you to modify the array of the default Widget fields.
apply_filters( 'carbon_twitter_widget_fields', array( Field::make( 'text', 'title', __( 'Title', 'carbon-twitter' ) ), Field::make( 'text', 'twitter_username', __( 'Twitter Username', 'carbon-twitter' ) ), Field::make( 'text', 'count_tweets', __( 'Number of Tweets to Display', 'carbon-twitter' ) ) ->set_default_value( 5 ), ) )
carbon_twitter_widget_classes
Allows you to modify the CSS classes that will be added to the Widget.
apply_filters( 'carbon_twitter_widget_classes', 'carbon-twitter-feed' )
Twitter Settings Carbon Container
carbon_twitter_settings_title
Allows you to change the title of the Twitter Settings Carbon Container.
apply_filters( 'carbon_twitter_settings_title', __( 'Twitter Settings', 'carbon-twitter' ) )
carbon_twitter_settings_page_parent
Allows you to change the Page Parent of the Twitter Settings Carbon Container.
apply_filters( 'carbon_twitter_settings_page_parent', 'crbn-theme-options.php' )
carbon_twitter_settings_custom_help_text
Allows you to modify the help text of the Twitter Settings Carbon Container.
carbon_twitter_settings_fields
Allows you to modify the default fields in the Twitter Settings Carbon Container.
apply_filters( 'carbon_twitter_settings_fields', array( Field::make( 'html', 'carbon_twitter_settings_html' ) ->set_html( carbon_twitter_get_options_help_text() ), Field::make( 'text', 'carbon_twitter_consumer_key', __( 'Consumer Key', 'carbon-twitter' ) ), Field::make( 'text', 'carbon_twitter_consumer_secret', __( 'Consumer Secret', 'carbon-twitter' ) ), Field::make( 'text', 'carbon_twitter_access_token', __( 'Access Token', 'carbon-twitter' ) ), Field::make( 'text', 'carbon_twitter_access_token_secret', __( 'Access Token Secret', 'carbon-twitter' ) ), ) )
htmlburger/carbon-twitter 适用场景与选型建议
htmlburger/carbon-twitter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 594 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「twitter」 「feed」 「twitter feed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 htmlburger/carbon-twitter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 htmlburger/carbon-twitter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 htmlburger/carbon-twitter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
Simple Twitter API wrapper
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Simple RSS generator library for PHP 5.5 or later. clone from Bhaktaraz Bhatta ttps://github.com/bhaktaraz/php-rss-generator
A helper module for pdf-print, print and social share functionality based on bootstrap to custom modules.
Laravel package for the simplification and integration of many of your users most wanted login providers. Installation is a breeze. Never worry about OAuth again.
统计信息
- 总下载量: 594
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2017-08-28