michaelhall/link-sharer

Link sharer helper for sharing links on social networks

v2.2.0 2018-10-15 20:42 UTC

This package is auto-updated.

Last update: 2020-03-23 00:28:06 UTC


README

Build Status AppVeyor codecov.io StyleCI License Latest Stable Version Total Downloads

Link sharer helper for sharing links on social networks.

Requirements

  • PHP >= 7.1

Install with composer

$ composer require michaelhall/link-sharer

Basic usage

<?php

require __DIR__ . '/vendor/autoload.php';

$url = \DataTypes\Url::parse('http://example.com/');

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

$linkSharer = new \MichaelHall\LinkSharer\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->getGooglePlusSharer();
echo $linkSharer->getLinkedInSharer();
echo $linkSharer->getRedditSharer();
echo $linkSharer->getTumblrSharer();

License

MIT