PHP code example of htmlburger / carbon-twitter

1. Go to this page and download the library: Download htmlburger/carbon-twitter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

htmlburger / carbon-twitter example snippets


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;
}

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;
}

apply_filters( 'carbon_twitter_widget_id', 'carbon_twitter_feed_widget' );

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

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

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

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

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

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

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