PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Jackson Morais   PHP Twitter Share Button   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Twitter Share Button
Generate HTML for button to share page on Twitter
Author: By
Last change:
Date: 5 years ago
Size: 1,680 bytes
 

Contents

Class file image Download

Twitter Sharer - Docs

Create quick and easy tweet buttons!

Build Status

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