PHP code example of michaelhall / link-sharer

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

    

michaelhall / link-sharer example snippets




ataTypes\Net\Url;
use MichaelHall\LinkSharer\LinkSharer;

$url = Url::parse('https://example.com/');

// $text and $hashtags parameters are optional.
$text = 'My Webpage';
$hashtags = ['my', 'webpage'];

$linkSharer = new LinkSharer($url, $text, $hashtags);

// Prints https://twitter.com/intent/tweet?url=...
echo $linkSharer->getTwitterSharer();

// Prints https://www.facebook.com/sharer/sharer.php?u=...
echo $linkSharer->getFacebookSharer();

// And so on...
echo $linkSharer->getLinkedInSharer();
echo $linkSharer->getRedditSharer();
echo $linkSharer->getTumblrSharer();