TheoryApp
  • Home
  • Java
Home › Web › Add Social Buttons: Facebook, Google, Twitter, Pinterest

Add Social Buttons: Facebook, Google, Twitter, Pinterest

Posted on November 15, 2013 by theoryapp

There are many services online providing all-in-one widgets for social sharing, such as AddThis, ShareThis, etc. However, it is better to build your own one:

  • You don’t want to show your web traffic to others.
  • Too many sharing buttons are useless.
  • It’s enough to have Facebook Like, Twitter Tweet, Google PlusOne and Pinterest PinIt.
  • It is simple and easy, as we show below.

Facebook Like Button

The following code uses iframe to embed a Facebook Like button. We use the URL “http://theoryapp.com/” in the examples. We need to encode this URL so it can be used in query strings for social sharing URLs. The PHP function urlencode does this dynamically.

$url = "http://theoryapp.com/";
$eurl = urlencode($url);       // http%3A%2F%2Ftheoryapp.com%2F

The result is shown below. For details see the facebook document.

Google PlusOne Button

The following code embeds a Google +1 button. To use it, just replace the URL part with your own one.

The result is shown below. For details see the google document.

Twitter Tweet Button

The following code embeds a Twitter Tweet share button for the current page.

The result is shown below. For details see the twitter document.

Tweet

Pinterest PinIt Button

The following code embeds a Pinterest PinIt button for the current page. Note that the page must have some image to be pinned.

The result is shown below. For details see the pinterest document.

Summary

It seems Facebook Like button requires a “href” parameter for the web page to be liked. For the other buttons, by default, they use the URL for the current page where the button is showing, although you can customize the URL by adding parameters.

The official documents:

  • Facebook Like button
  • Google PlusOne button
  • Twitter Tweet share button
  • Pinterest PinIt button

Comments

comments

‹ Unix Zip/Unzip Command
k-wise Independence and Linear Code ›
Tagged with: facebook like, google plusone, pinterest pinit, social sharing, twitter tweet
Posted in Web

Recent Posts

  • Impagliazzo’s Hardcore Lemma and Computational Hardness
  • Searching and Replacing with grep and sed
  • Turn Off Voice Assistant on Apple Mac
  • A Double Sum of Binomials
  • Chernoff Bound
  • Store compressed data in database using PHP
  • Format numbers with leading and trailing zeros in PHP
  • Sperner Theorem on Maximal Antichains
  • Kolmogorov Complexity
  • Unix Commands for Large Files

Categories

  • Algorithm
  • BigData
  • Combinatorics
  • DevTool
  • HowTo
  • Java
  • JavaScript
  • MySQL
  • PHP
  • Probability
  • SQL
  • Theory
  • Uncategorized
  • Web

Tags

abstract class abstract method ArrayList boolean function chernoff bound class CSS derandomization divide and conquer dom endswith expression FIFO fourier analysis generic type geocoding google maps html inheritance interface java java collection JavaScript lifo loop mysql object-oriented parser PHP polymorphism probability programming pseudorandom generator random random walk recursion regular expression rss seo sql startswith store locator string twitter xml

Archives

  • May 2016
  • March 2016
  • May 2015
  • February 2015
  • December 2014
  • August 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • February 2013
  • January 2013
  • December 2012

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
    © 2022 TheoryApp
    ↑
    Responsive Theme powered by WordPress