michaelhall/link-sharer

This package is abandoned and no longer maintained. No replacement package was suggested.

Link sharer helper for sharing links on social networks

v3.0.0 2022-09-14 15:13 UTC

This package is auto-updated.

Last update: 2024-10-23 17:55:52 UTC


README

Tests StyleCI License Latest Stable Version Total Downloads

Link sharer helper for sharing links on social networks.

Requirements

  • PHP >= 8.0

Install with composer

$ composer require michaelhall/link-sharer

Basic usage

<?php

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

use DataTypes\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();

License

MIT