drmonkeyninja/social-share-url

A standalone utility library for generating URLs to share content on numerous social media platforms.

1.4.0 2019-09-27 18:03 UTC

This package is auto-updated.

Last update: 2024-10-28 04:36:23 UTC


README

Build Status Latest Stable Version

A standalone utility library for generating URLs to share content on numerous social media platforms.

Social Share currently supports Delicious, Digg, Evernote, Facebook, Friend Feed, Google Bookmarks, Hacker News, LinkedIn, Newsvine, Pinterest, Pocket, Reddit, Slashdot, simple email, StumbleUpon, Technorati, Tumblr, Twitter, VK, WhatsApp and Xing.

Requirements

  • Composer

Installation

Install via Composer:-

composer require drmonkeyninja/social-share-url ~1

Usage

To generate a social share URL simply use the getUrl() method passing it the name of the social network you want to link to and the URL of the page you want to share:-

use \drmonkeyninja\SocialShareUrl\SocialShareUrl;

$SocialShareUrl = new SocialShareUrl();
$url = $SocialShareUrl->getUrl('facebook', 'http://example.com');

You can pass further parameters to be included in the share URL by passing them as an array to the third parameter:-

$url = $SocialShareUrl->getUrl(
	'facebook',
	'http://example.com'
	['text' => 'Hello World']
);

Supported parameters include:-

  • text
  • image

A full list of the available social networks can be found in the src/data/stubs.php file. You can also return a full list of the social networks supported by SocialShareUrl by using the getServices() method:-

$services = $SocialShareUrl->getServices();

License

The MIT License.