drmonkeyninja / social-share-url
A standalone utility library for generating URLs to share content on numerous social media platforms.
Installs: 4 973
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
README
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.