PHP code example of minetro / social

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

    

minetro / social example snippets


use Contributte\Social\Facebook\LikeButton;
use Contributte\Social\Facebook\Script;

protected function createComponentLikeButton()
{
    $button = new LikeButton();
    $attrs = $button->getAttributes();

    // URL - manually
    $attrs->add('data-url', $this->link('Home:default'));

    // URL - current
    $attrs->add('data-url', $this->link('//this'));

    // Add other attributes

    $attrs->add('data-layout', $button::LAYOUT_BUTTON_COUNT);
    // OR
    $attrs->data('layout', $button::LAYOUT_BUTTON_COUNT);

    return $button;
}

protected function createComponentScript()
{
    $script = new Script();
    $script->setApiVersion("v2.6");
    $script->setAppId(123456);

    return $script;
}

use Contributte\Social\Google\PlusOne;

protected function createComponentPlusone() {
    $button = new PlusOne();
    $button->setMode($button::MODE_DEFAULT);
    $button->setUrl('www.google.com');

    return $button;
}

/** @var Contributte\Social\Google\IPlusOneFactory @inject */
public $plusOneFactory;

protected function createComponentPlusone() {
    $button = $this->plusOneFactory->create();
    $button->setMode($button::MODE_DEFAULT);
    $button->setUrl('www.google.com');

    return $button;
}

use Contributte\Social\Google\Analytics\Campaign;

// Source, medium, campaign
$campaign = new Campaign('newsletter', 'website', 'april13');
$this->link('Card:detail', $campaign->build());

// Source, medium, campaign, term, content
$campaign = new Campaign('newsletter', 'website', 'april13', 'term1', 'content');
$this->link('Product:detail', $campaign->build());

// Factory (same args as previous)
$link = Campaign::create('newsletter', 'website', 'april13');
$this->link('Foto:detail', $link);

use Contributte\Social\Twitter\TweetButton;

/**
  * @return TweetButton
  */
protected function createComponentPlusone() {
	$button = new TweetButton();
	$button->setShareButton('www.google.com');
	return $button;
}

/** @var Contributte\Social\Twitter\ITweetButtonFactory @inject */
public $twitterFactory;

/**
  * @return TweetButton
  */
protected function createComponentTwitter() {
	$button = $this->twitterFactory->create();
	$button->setShareButton('www.google.com');

	return $button;
}