Twitter Sharer - Docs
Create quick and easy tweet buttons!
Instalation
It's recommended that you use Composer to install Twitter Sharer.
$ composer require jkmorais/twitter-sharer
Twitter Sharer requires PHP 5.3.3 or newer.
Quick examples
Creating a custom tweet button
<?php
require 'vendor/autoload.php';
$tweet = new Sharer\Tweet;
$button = $tweet->button(
'Hello Twitter!', // the tweet text
'MyUsername', // via @MyUsername
'http://mywebsite.com', // the tweet url
Array(
'hashtag1', 'hashtag2', 'hashtag3' // the tweet hashtags
),
'large' // size of tweet button. This is an optional parameter. By default, the size of the button is 'small'
);
print $button;
To create a tweet button without url or without via username, just use [none] as a parameter.
$button = $tweet->button(
'Hello Twitter!',
'[none]',
'[none]',
Array(
'hashtag1', 'hashtag2', 'hashtag3'
)
);
To tweet the current page address, just use [this] as parameter in the URL
$button = $tweet->button(
'Hello Twitter!',
'MyUsername',
'[this]', // will be the current URL
Array(
'hashtag1', 'hashtag2', 'hashtag3'
)
);
Print (or echo) the $button
variable to show the tweet button
Where to get help
Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can catch me on Twitter