PHP code example of tatwerat / social-counter

1. Go to this page and download the library: Download tatwerat/social-counter 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/ */

    

tatwerat / social-counter example snippets


// use composer
use tatwerat\SocialCounter\SocialCounter;

// quire "./SocialCounter.php";

$SocialCounter = new SocialCounter([
    'facebook_id' => '{user_id}',
    'twitter_id' => '{user_id}',
    'youtube_id' => '{user_name or channel id}',
    'dribbble_id' => '{user_id}',
    'github_id' => '{user_id}',
    'soundcloud_id' => '{user_id}',
    'behance_id' => '{user_id}',
    'instagram_id' => '{user_id}',
    'google_api_key' => 'xxxxxxxx',
    'dribbble_access_token' => 'xxxxxxxxxxxxxx',
    'soundcloud_api_key' => 'xxxxxxxxxxxxxx',
    'behance_api_key' => 'xxxxxxxxxxxxxx',
]);
 
$SocialCounter->cache = true; // Cache Social Counts ( improvement the loading of your server )


$counts_data = $SocialCounter->print_data();
echo $counts_data['facebook'];
echo $counts_data['twitter'];
echo $counts_data['instagram'];
echo $counts_data['youtube'];
echo $counts_data['dribbble'];
echo $counts_data['behance'];
echo $counts_data['soundcloud'];
echo $counts_data['github'];

echo $SocialCounter->facebook_count();
echo $SocialCounter->twitter_count();
echo $SocialCounter->youtube_count(); // parameter ($type = 'channel' or 'user') : default value='channel'
echo $SocialCounter->dribbble_count();
echo $SocialCounter->github_count();
echo $SocialCounter->soundcloud_count();
echo $SocialCounter->behance_count();
echo $SocialCounter->instagram_count();