2017 © Pedro Peláez
 

library carbon-twitter

Helper library for retrieving information from the Twitter API.

image

htmlburger/carbon-twitter

Helper library for retrieving information from the Twitter API.

  • Monday, August 28, 2017
  • by htmlburger-git
  • Repository
  • 4 Watchers
  • 2 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 12 % Grown

The README.md

Carbon Twitter

Helper library for retrieving tweets from the Twitter API., (*1)

Installation

The library is available as Composer package. You can include it in your Project with:, (*2)

composer require htmlburger/carbon-twitter, (*3)

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:, (*4)

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, (*5)

The api parameter holds an array of 4 elements:, (*6)

  • access_token
  • access_token_secret
  • consumer_key
  • consumer_secret

cache_lifetime (int) - optional, (*7)

The cache duration defined in seconds. Defaults to 300 seconds (5 minutes), (*8)

verbose (boolean) - optional, (*9)

Whether to enable Verbose mode. Defaults to false., (*10)

cache_drivers (array) - optional, (*11)

An array of Cache Drivers to use. Uses the first Driver which is supported in the Project environment. Defaults to array( 'WordPress', 'File' ), (*12)

In WordPress environment

Once the library is installed in your WordPress project, the receive the following features out of the box:, (*13)

  • 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, (*14)

Carbon_Twitter_Feed_Widget

carbon_twitter_widget_id, (*15)

Allows you to modify the Widget ID., (*16)

apply_filters( 'carbon_twitter_widget_id', 'carbon_twitter_feed_widget' );

carbon_twitter_widget_title, (*17)

Allows you to modify the default Widget title., (*18)

apply_filters( 'carbon_twitter_widget_title', __( 'Carbon Twitter Feed', 'carbon-twitter' ) )

carbon_twitter_widget_description, (*19)

Allows you to modify the default Widget description., (*20)

apply_filters( 'carbon_twitter_widget_description', __( 'Displays a Twitter Feed.', 'carbon-twitter' ) )

carbon_twitter_widget_fields, (*21)

Allows you to modify the array of the default Widget fields., (*22)

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, (*23)

Allows you to modify the CSS classes that will be added to the Widget., (*24)

apply_filters( 'carbon_twitter_widget_classes', 'carbon-twitter-feed' )

Twitter Settings Carbon Container

carbon_twitter_settings_title, (*25)

Allows you to change the title of the Twitter Settings Carbon Container., (*26)

apply_filters( 'carbon_twitter_settings_title', __( 'Twitter Settings', 'carbon-twitter' ) )

carbon_twitter_settings_page_parent, (*27)

Allows you to change the Page Parent of the Twitter Settings Carbon Container., (*28)

apply_filters( 'carbon_twitter_settings_page_parent', 'crbn-theme-options.php' )

carbon_twitter_settings_custom_help_text, (*29)

Allows you to modify the help text of the Twitter Settings Carbon Container., (*30)

carbon_twitter_settings_fields, (*31)

Allows you to modify the default fields in the Twitter Settings Carbon Container., (*32)

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' ) ),
  ) )

The Versions

28/08 2017

dev-master

9999999-dev

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

The Requires

 

feed twitter twitter feed

28/08 2017

v2.0.0

2.0.0.0

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

The Requires

 

feed twitter twitter feed

28/08 2017

dev-refactor

dev-refactor

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

The Requires

 

feed twitter twitter feed

27/06 2016

v1.0.2

1.0.2.0

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

The Requires

 

12/02 2016

v1.0.1

1.0.1.0

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

The Requires

 

by 2create Studio

26/01 2016

v1.0.0

1.0.0.0

Helper library for retrieving information from the Twitter API.

  Sources   Download

GPL-2.0

by 2create Studio