In my previous post I had explained about how to fetch facebook cover page using jQuery.  Now I am going to explain how to get facebook fan page details using jQuery Ajax Method called  – jQuery.getJSON()

Facebook Fan Page Details using jQuery

Facebook Fan Page Details using jQuery

jQuery Code will get you

  1. Fan Page Name
  2. Fan Page Cover Page
  3. People Talking about Count
  4. No of Likes
  5. About
  6. Username
  7. Fan Page Category
  8. Website Link
  9. Fan Page Link & much more

jQuery Code to fetch fan page details

//code to fetch fan page details
jQuery.getJSON('http://graph.facebook.com/'+username+'?callback=?', function(data){
				var fb_count = data['likes'].toString();
				var fb_about = data['about'].toString();
				var fb_name = data['name'].toString();
				var fb_category = data['category'].toString();
				var fb_founded = data['founded'].toString();
				var fb_talking_count = data['talking_about_count'].toString();
				var fb_website = data['website'].toString();
				var fb_link = data['link'].toString();
				fb_count = add_commas(fb_count);
				fb_talking_count = add_commas(fb_talking_count);

				$('.facebook_about').html(fb_about);
				$('.facebook_likes').html(fb_count);
				$('.facebook_name').html(fb_name);
				$('.facebook_link').html(fb_link);
				$('.facebook_website').html(fb_website);
				$('.facebook_talk_count').html(fb_talking_count);
				$('.facebook_category').html(fb_category);
				$('.facebook_founded').html(fb_founded);
				$('.facebook_cover_page').html('<img src="'+ data.cover.source + '">');
});

Javascript Code for adding commas in numbers of four or more digits

function add_commas(number) {
		if (number.length > 3) {
			var mod = number.length % 3;
			var output = (mod > 0 ? (number.substring(0,mod)) : '');
				for (i=0 ; i < Math.floor(number.length / 3); i++) {
					if ((mod == 0) && (i == 0)) {
						output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
					} else {
						output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
					}
				}
			return (output);
		} else {
			return number;
		}
	}

Please don’t forget to share and subscribe to latest updates of the blog. Also any comments and feedback are all welcome!

Thanks!

View Live Demo

If you enjoyed this article, Get email updates (It’s Free)
http://w3lessons.info/wp-content/uploads/2013/07/facebook-fanpage-details-jquery.jpghttp://w3lessons.info/wp-content/uploads/2013/07/facebook-fanpage-details-jquery-150x150.jpgKarthikeyan KfacebookFreebiesjqueryfacebook,Jquery
In my previous post I had explained about how to fetch facebook cover page using jQuery.  Now I am going to explain how to get facebook fan page details using jQuery Ajax Method called  - jQuery.getJSON()jQuery Code will get youFan Page Name Fan Page Cover Page People Talking about Count No of Likes About Username Fan...