Tag Archives: Social Networking

Create Custom Google +1 Button

Social network by internet giant is “Google+” getting popular exponentially and of course they already have a huge customer database and all they have to do is to promote this new product among them.However people know the fact that Google+ is very special kind of social network with very unique features.


In parallel to Google+ they introduced +1 buttons for web masters.However the design of +1 button is non alterable and doesn’t go with most of the common web templates.If you already have +1 button, when you take your mouse over, it will pop up sharing window which is user unfriendly ūüôĀ


You can also create Google +1 and share button with your own icon by follow some very simple steps:


First step you need a suitable icon/image for Google+ share button.Find it and edit in the way you want.

Then you have to prepare Google+ share URL.


https://plus.google.com/share?url=YOUR URL (Replace ‘YOUR URL’ with actual page URL)


If you are using wordpress blog, you can use below code.
https://plus.google.com/share?url=<?php the_permalink(); ?>


If you want a pop up window use the below code.

[php]<a href="javascript:void(0);" onclick="popUp=window.open(‘https://plus.google.com/share?url=<span style="color: #ff0000;"><?php</span> the_permalink(); <span style="color: #ff0000;">?></span>’,’popupwindow’,’scrollbars=yes,width=800,height=400′);popUp.focus();return false">Share on Gogole+</a>[/php]

You can also update the link  with an image icon with below code.

[php]<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>"><img src="your-custom-google-plus-icon/path/gplus.jpg" alt="Google+" title="Google+" /></a>[/php]

Share your WordPress page URL on social networking website by using a simple function

Share your WordPress post on facebook & other social networking website.


If you want to share your WordPress page URL on social networking website, it’s very simple to do.

Just place this function in your functions.php file, and call the function where do you want it to show.



function GetShareLinks() {

/* Your current page URL */
$URI = get_permalink();

/* The js script used for goolge plus share button */
$sharestring ='<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>’;

$sharestring .='<a href="https://pinterest.com/scriptarticle/" target="_blank"><img width="16" height="16" alt="Follow Me on Pinterest" src="http://passets-lt.pinterest.com/images/about/buttons/small-p-button.png"></a>
<a href="http://www.facebook.com/sharer.php?u=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/facebook.jpg" alt="" /></a>
<a href="http://twitter.com/intent/tweet?text=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/twitter.jpg" alt="" /></a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/in.jpg" alt="" /></a>
<g:plusone count="false" size="small"></g:plusone>’;

return $sharestring;




You can also use this function in other website (non WordPress) site, you have to just replace the get_permalink() function by current page URL and update the social icons images path.


If you face any issue to use this, put your comment, I’ll help you ūüôā


PHP script for getting latest Tweets of a user

There are so many different ways to get tweets to display on your blog or web page,¬†unfortunately¬†most of these use JavaScript which means that the tweets displayed are not made available to search engines ūüôĀ


Don’t worry; you can also display your latest Twitter tweets using¬†PHP. You¬†can achieve by following very simple functions.


function getLastestTweets fetches latest tweets

It require 2 parameters
$userid = User Id of the twitter account
$x         = number of tweets to be fetched


function getLastestTweets($userid,$x){
$url = "http://twitter.com/statuses/user_timeline/$userid.xml?count=$x&quot";
$xml = simplexml_load_file($url) or die(‘could not connect’);
echo ‘<ul>’;
foreach($xml->status as $status){
$text = twitterify( $status->text );
echo ‘<li>’.utf8_decode($text).'</li>’;

$time = dateDiffForTweet(date("Y-m-d H:i:s"),date("Y-m-d H:i:s",strtotime($status->created_at)));
if(!sizeof($time)){ $time[0]= ‘1 second’; }
echo " ".$time[0]." ago";
echo ‘</ul>’;


function twitterify automatically converts hashtags (like #scriptarticle) to tag links, @links to author links (like @mahesh), and autolinks URIs (like http://scriptarticle.com ) to links.


function twitterify($ret) {
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" >\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" >\\2</a>", $ret);
$ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" >@\\1</a>", $ret);
$ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" >#\\1</a>", $ret);
return $ret;


function dateDiffForTweet is used for showing time difference between tweet posted and current, like 2 mins ago,2 days ago


function dateDiffForTweet($time1, $time2, $precision = 6) {
// If not numeric then convert texts to unix timestamps
if (!is_int($time1)) {
$time1 = strtotime($time1);
if (!is_int($time2)) {
$time2 = strtotime($time2);

// If time1 is bigger than time2
// Then swap time1 and time2
if ($time1 > $time2) {
$ttime = $time1;
$time1 = $time2;
$time2 = $ttime;

// Set up intervals and diffs arrays
$intervals = array(‘year’,’month’,’day’,’hour’,’minute’,’second’);
$diffs = array();

// Loop thru all intervals
foreach ($intervals as $interval) {
// Set default diff to 0
$diffs[$interval] = 0;
// Create temp time from time1 and interval
$ttime = strtotime("+1 " . $interval, $time1);
// Loop until temp time is smaller than time2
while ($time2 >= $ttime) {
$time1 = $ttime;
// Create new temp time from time1 and interval
$ttime = strtotime("+1 " . $interval, $time1);

$count = 0;
$times = array();
// Loop thru all diffs
foreach ($diffs as $interval => $value) {
// Break if we have needed precission
if ($count >= $precision) {
// Add value and interval
// if value is bigger than 0
if ($value > 0) {
// Add s if value is not 1
if ($value != 1) {
$interval .= "s";
// Add value and interval to times array
$times[] = $value . " " . $interval;

return $times;
// Return string with times
//return $times;
// return implode(", ", $times);


Here is the way; you can display your tweets


//my userid scriptarticle


If you face any issue to implement the code just left a comments below the post.

Integrate Twitter Widget to add to your website

The twitter updates are always short – under 140 characters each. Plus, one can post updates and follow her friends using the Twitter website, software on his browser, a mobile phone or instant messages. People¬†aren’t¬†tied to one device. This makes the twitter so popular.


It has grown far beyond its microblogging roots to become a fabulous tool for social messaging.

Many people use Twitter clients to update their status and read tweets, but there are also a host of useful Twitter widgets that allow you to check your tweets from your blog/website or even let people re-tweet your blog entries.


Display your Twitter updates on your website like this.


This is one of Twitter widgets that will let you take your status updates and put them up anywhere that allows custom widgets. The great thing about the Twitter Profile Widget is that you can put your tweets on a loop.


Twitter provide very rich widgets, where you can easily manage it’s width, height, background¬†colour, text¬†colour, links, number of tweets, loop scroll¬†etc.


You can produce the code by follow the below link