Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP.

Written By: Zeeshan Rasool  |  Posted In: AJAX, JQuery, PHP, Web Development

These days every website must contain a section that is called “Share This”. After creating facebook style posting and youtube style rating system I have now come to share button. I have created youtube style share button with url shortening script. Try the demo and use this awesome tutorial on your web pages. Hope you will like this.

jQuery Code

 $(document).ready(function() {
        $('.share_button').mouseenter(function(e) {
			$('.tooltip').show();
            $('.share_this').fadeIn(200);
        }).mouseleave(function(e) {
			$('.share_this').fadeOut(200);
			$('.tooltip').hide();
        });
		
		$('.share_button').click(function(){
			$('#load_buttons_box').fadeIn();
		});	
    });
	
$(document).ready(function(){	
	
	$('#shortLink').click(function(){
	
		if($('#shortLink').is(':checked'))
		{
			$('#setURL').val($("#shareLink").val()); // to save previous link
			var a = $("#shareLink").val();
		
			$.post("getShortLink.php?value="+a, {
			}, function(response){
				$('#shareLink').val(response);
			});
		}
		else
		{
			$('#shareLink').val($('#setURL').val());
		}
	});	
	
	$('.close').click(function(){
		$('#load_buttons_box').fadeOut();
	});	
});	

CSS

button {
	-moz-background-clip:border;
	-moz-background-inline-policy:continuous;
	-moz-background-origin:padding;
	-moz-border-radius-bottomleft:5px;
	-moz-border-radius-bottomright:5px;
	-moz-border-radius-topleft:5px;
	-moz-border-radius-topright:5px;
	background:#F6F6F6 none repeat scroll 0 0;
	border:1px solid #CCCCCC;
	cursor:pointer;
	padding:5px;
	height:2.0833em;
	overflow:visible;
	vertical-align:middle;
	white-space:nowrap;
}

.share_button{background:url(share.png) center left no-repeat; padding-left:50px; }

.facebook_button{background:url(facebook.png) center left no-repeat; padding-left:20px; float:left }

.tooltip{ height:13px;display: none;width:120px; text-align:left;overflow:visible}

.share_this{
		display: none;
		font-size: 1.0em;
		height:17px;
		padding:7px;
		-moz-border-radius: 6px; 
		-webkit-border-radius: 6px;
		-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.6);
		-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.6);
		text-align: center;
		text-decoration: none;
		width:60px;
		background-color:#333333;
		color:#FFFFFF;
		text-shadow: #fff 0px 0px 20px;
	}

#load_buttons_box{ 
		border:solid #666666 1px; height:140px; 
		margin-top:19px;-moz-border-radius: 6px;
		display:none;
		padding-left:30px;
		-webkit-border-radius: 6px; width:500px;
		}
		
.twitter_button{background:url(twitter.png) center left no-repeat; padding-left:20px; float:left; margin-left:4px;  }

.buzz_button{background:url(buzz.png) center left no-repeat; padding-left:25px; float:left; margin-left:4px;  }

.bebo_button{background:url(bebo.gif) center left no-repeat; padding-left:21px; float:left; margin-left:4px;  }

.stumbleupon_button{background:url(stumbleupon.gif) center left no-repeat; padding-left:20px; float:left; margin-left:4px;  }


.share_button:hover, .facebook_button:hover, .twitter_button:hover, .buzz_button:hover, .bebo_button:hover, .stumbleupon_button:hover{
	-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.6);
	-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
		
.mesgbox{
	padding-left:25px;  
	margin:5px;
	font-family:Arial, Helvetica, sans-serif; 
	font-size:12px; height:20px;  
	width:427px; float:left}

.close{ 
	border:solid #666666 1px; 
	float:left; 
	width:20px; margin-top:6px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;  text-align:center; 
	font-size:12px; cursor:pointer; 
	background-color:0 1px 3px rgba(0,0,0,0.6);
}

.textBox{ 
	background:url(ico.png) center left no-repeat;
	height:22px;
	width:300px;
	padding-left:25px;
	font-family:Arial, Helvetica, sans-serif;
	font-size:13px;
}
#shortLink{ 
	margin-top:10px;
	}
.textBox label{ cursor:pointer;}

getShortLink.php


HTML




 
X





If you enjoyed this post, please consider leaving a comment below or subscribing to the RSS feed to have future articles delivered to your feed reader. You can also follow us on Facebook or Twitter @99Points


Zeeshan Rasool is the founder and editor of this blog. Beside this, he is an experienced PHP web developer and freelancer. He loves to create best and interactive web apps. You can follow him at twitter @99_Points and facebook OR drop an email at 99points.info@gmail.com

31 to “Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP.”

  • Avinash July 17, 2010 at 11:26 am

    Cool way of using an API :)
    what about the download link ? why do we have to wait to download the file, can’t we download it from this blog

  • Abdelhadi Touil July 20, 2010 at 11:02 am

    Very nice tutorial! Thanks for sharing..
    for the download link I think there are a lot of nice hosting service better than easy-share.com, except if you are using it for some reason (ads for example if there is…)
    I suggest you use Skydrive from Microsoft, it’s 25Go for free, and without waiting to doanload, and you can upload up to 50 Mb per file.
    Personaly I use it.
    Thanks again and good luck.

  • 185+ Breathtaking Collection of Fresh Articles for Web Designers and Developers | tripwire magazine July 20, 2010 at 6:23 pm

    [...] Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP. [...]

  • ZeeShaN July 20, 2010 at 7:42 pm

    @Abdelhadi Touil, thanks bro. I will fix the downloading problem within 2 or 3 days. You will see no more waiting in next coming days.
    Thanks and keep looking for new tutorials

    Regards,
    Zee

  • MACHBIO July 21, 2010 at 6:19 am

    can i use a different api like PHURLS.com or something.. i just need to take my own getshortlinks.php

  • ZeeShaN July 21, 2010 at 11:50 am

    Well, MACHBIO, I didn’t check with that. So I have no idea about it. You need to have a try.

  • jQuery tuts en inglés | gorkaerrea.com | diseño bilbao August 11, 2010 at 10:46 am

    [...] Demo Download [...]

  • micha August 21, 2010 at 3:25 pm

    sorry my last comment was for: http://demos.99points.info/ajax_star_rating/
    your link “Back to tutorial” is wrong.. it points to this website ;)

  • ZeeShaN August 21, 2010 at 3:27 pm

    thanks Micha, its updated now

  • Hiran August 29, 2010 at 5:43 pm

    Awesome scripts. Nice work. Thanks. I am going to download and use.

  • Mixer Shower  October 21, 2010 at 2:15 am

    everyone is addicted to youtube, and everyonle like to upload videos on youtube.:~

  • All Time Most Popular JQuery Tutorials of 99Points | 99Points December 15, 2010 at 11:11 am

    [...] Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP. [...]

  • » [jQuery]Youtube風のソーシャルサービスボタンを実装するJ-snippet January 4, 2011 at 4:18 pm

    [...] Youtube Style Share Button With URL Shortening using CURL [...]

  • milanzitka January 24, 2011 at 11:23 am

    Hi, first thank you for great script!

    I don’t have a lot experience with JS and PHP, so could anyone help me, how to integrate Goo.gl instead of Tinyurl? Thank you very much!

  • ZeeShaN January 24, 2011 at 3:46 pm

    Thanks milanzitka :)
    I didnt use goo.gl but why you want to use goo.gl instead of tinyurl?

  • milanzitka January 25, 2011 at 12:08 pm

    Well, I’m just big fan of everything from Google and IMHO goo.gl links are shorter and “nicer” than tinyurl. :)

  • Mirrored Furniture January 25, 2011 at 12:11 pm

    ‘:` I am really thankful to this topic because it really gives useful information ~..

  • 25 Web Devlopment Resources » SUBMIT SITE SEO TOOLS AND SERVICES - FREE SEO SERVICES February 21, 2011 at 10:47 am

    [...] 21. Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP [...]

  • Latest jQuery Plugins Write Less Do More Javascripts Episode - 5 August 5, 2011 at 12:52 pm

    [...] Demo Download [...]

  • security system August 14, 2011 at 4:37 pm

    I just now are in possession of encountered your blog post earlier liked working out already have definitely felt reviewing have in mind this amazing onto a routine. Afterward you have many of ideas right after then i indulge in try to get such online worlds success. Dancing most of the quality profession!

  • theadsbook August 20, 2011 at 10:05 am

    very Useful Script,
    Thanks for Sharing

  • ZeeShaN August 22, 2011 at 6:06 pm

    you welcome :)

  • arie August 26, 2011 at 5:08 pm
  • ZeeShaN August 28, 2011 at 8:34 am

    welcome :)

  • arie October 16, 2011 at 2:22 pm

    how to create login form, for web???

  • mey October 21, 2011 at 1:27 am

    Nice job!!!!!!!

  • Sal November 2, 2011 at 9:07 pm

    I really like this work, along with the rating script as well. I would like to use both on the same page but every time I try to combine the two, when you click on the first item it opens the second as well. How can I use both side-by-side?

  • rohit singh November 30, 2011 at 9:45 am

    i should be want join your e mail id , i am working in php project ,major problem create so i want help u plz help me

  • saroj December 7, 2011 at 7:10 am

    hi the script is very nice. But some bug is there in captcha code validation. If we press submit without entering any character then its working fine but when we enter some character like “abcde” it is accepting and showing success message.

  • 50 Essential PHP Tutorial and Examples for Beginners | SEO Approved June 16, 2012 at 11:24 am

    [...] 43. URL Shortening using CURL, jQuery and PHP [...]

Post comment


Email Subscriber!

Be the first to know about new updates


Advertisement

Categories

Popular post

Recommend