Amit Dhamu

Writes Code

Social Bookmark Share Function

Function

function Socialise($service, $link, $title = "") {
   switch($service) {
        case "twitter": return "https://twitter.com/intent/tweet?original_referer=$link&text=".$title."&url=$link"; break;
      case "facebook": return "http://www.facebook.com/share.php?u=$link"; break;
       case "google+": return "https://plusone.google.com/_/+1/confirm?hl=en&url=$link&title=$title"; break;
     case "digg": return "http://digg.com/submit?url=$link&title=$title"; break;
       case "delicious": return "http://del.icio.us/post?url=$link&title=$title"; break;
 }
}


Usage

// Outputs https://twitter.com/intent/tweet?original_referer=http://my-website.co.uk&text=Google Search&url=http://google.co.uk
$twitter_share = Socialise("twitter", "http://google.co.uk", "Google Search");

//Note: You may want to add urlencode to the function somewhere to make the URL safe


twitter / facebook / google plus / digg / delicious / social networking / php

← Recursive Directory Scanning Self Executing Function →