How to use Google AJAX API Search to embed video Search in ASP.NET

No.of Views3022
Bookmarked0 times
Downloads 
Votes0
By  NikhilJohari   On  22 Aug 2010 02:08:35
Tag : ASP.NET , General
Google has launched Ajax API for different purposes video search is one of them. Many user's gets confused all about it many times how to get google key, how to embed video search in web application. So here I am explaining how to use video search in web application.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

Google has launched Ajax API for different purposes “video search” is one of them.Many users’ gets confused all about it many times how to get Google key, how to embed video search in web application.

So here I am explaining how to use video search in web application.

Getting Google Search API Key

First you have to get the Google search API key for this http://code.google.com/apis/ajaxsearch/signup.html Visit here and fill the information and then use of gmail account to get the API key.

Note: You can get a gmail account free

The key page will look like this.

 

Image Loading

How to use this code

Now copy the whole HTML code, 

Image Loading

This is the code for “WebSearch”, Video Search and Blog Search but you have to use only the “Video Search” For this the next step.

Video Search

If you listen about Google Code (presented by Google), You have to take the video search control from there.which is like following.Just replace the above code with this,

google.load('search', '1');

 function OnLoad() {// create a search controlvar searchControl = new google.search.SearchControl();// So the results are expanded by defaultoptions = new google.search.SearcherOptions();
  options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);// Create a video searcher and add it to the controlsearchControl.addSearcher(new google.search.VideoSearch(), options);

Then the whole code will look like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>My Google AJAX Search API Application</title><script src="http://www.google.com/jsapi?key=ABQIAAAABE_5tJYjIxZez706qj8fKhSHXJsp5oogWH5jZodYSc2VMsh-GBTebFLwydk8evvTefXYLwNiLYMO_A" type="text/javascript"></script><script language="Javascript" type="text/javascript">//<![CDATA[

    google.load('search', '1');

function OnLoad() {

  // create a search control
  var searchControl = new google.search.SearchControl();

  // So the results are expanded by defaultoptions = new google.search.SearcherOptions();
  options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);

  // Create a video searcher and add it to the control
  searchControl.addSearcher(new google.search.VideoSearch(), options);

  // Draw the control onto the page
  searchControl.draw(document.getElementById("searchcontrol"));

// Search for a YouTube channel
searchControl.execute(
"ytchannel:NBA"); } google.setOnLoadCallback(OnLoad); //]]></script></head><body><div id="searchcontrol">Loading...</div></body></html>

 Output 

Image Loading

Formating the Output

If you want to format the output then you can use the style tag.Just use this code after closing the </script> tag.

<style type="text/css">body{font-family:Arial Rounded MT Bold;background-color:Silver;}#searchcontrol{background-color:ActiveBorder;width:50%;margin-left:auto;margin-right:auto;text-align:left;}<style/>

 Output 

Image Loading

Note: In my next upcoming article I’ll examplain the whole search techniquies of GOOGLE.

Conclusion

We learned how to get the google Ajax search API key and how to use video search in our web application.

Sample Project Source

Download source files -1 kb

 
Sign Up to vote for this article
 
About Author
 
NikhilJohari
Occupation-
Company-
Member Type-Senior
Location-India
Joined date-15 Aug 2009
Home Page-http://fast-get.com
Blog Page-http://dotnetask.blog.co.in
 
 
Other popularSectionarticles
    In visual studio 2008 nested master page concept is introduced, to make page template
    Published Date : 16/Feb/2010
    The problem arises when you install IIS after installing ASP.NET. If you do this, IIS will configure itself for the ASP.NET version that ships with your Windows edition that might be an older version (e.g. version 2.0) and you won’t be able to run any web application built using a later version of ASP.NET.
    Published Date : 21/Jan/2011
    This is just a helper article which may help you to decide which technology you might want to go.
    Published Date : 20/Aug/2010
    This article I am going to discuss function which convert numeric value to word for that we create one web page which return convert number to word.
    Published Date : 13/Oct/2011
    Set Start Up page on Visual studio IDE
    Published Date : 02/Aug/2011
Comments
By:escortDate Of Posted:2/6/2011 5:38:50 PM
escort is say tanks
thank for this document.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top
</