Archive

Archive for the ‘Google’ Category

Consuming Services: Yahoo! API vs. Google API

October 29, 2007 1 comment

As both a proof of concept for some internal uses as well as demonstration, I’ve been doing a bit of research into how the Yahoo! and Google APIs work—especially in .NET.  Here’s a bit of a comparison of what I’ve found so far.  I welcome any comments and such as I’m quite sure others out there have been using these technologies far longer than I have—and may have some workarounds for the odd glitches found in each framework.

Yahoo! Developer API

I’ll start out that I’m quite impressed by Yahoo!.  The Developer API was introduced to me in an AJAX session I attended a few months ago and I had totally forgotten about it until recently.  Their .NET Developer Center provides articles, SDK libraries, and most anything you’d need to wrap Yahoo! functionality into your .NET Application. Since Yahoo! returns standard XML (or JSON if you so desire and want to use the FromJson extension method and a custom type), I built a quick console-based searcher app.  The UI is irrelevant, I simply wanted to see how fast I could take data, search for it, and return information.

Most of the code here can be gleamed from the Yahoo! examples…

static void Main(string[] args)

{

// Capture the Yahoo query from the console.

       Console.WriteLine(“Your query to http://www.yahoo.com’s Image Search engine:”);

       string query = Console.ReadLine();

       // If query is blank, end.

       if (query == “”) return;

                      

       foreach (XmlNode node in GetImageSearch(query))

       {

              Console.WriteLine(“{0} @ {1}”,

node[“Title”].InnerText,

node[“Url”].InnerText);

}

}

This bit of code takes the input (from the console at this point) and then searches.  My GetImageSearch method returns an XmlNodeList (encapsulating the whole “get an XML, convert it, get the elements, etc” process) and then allows us to iterate through it, set it to a DataSet, etc.

static XmlNodeList GetImageSearch(string query)

{

// Create the web request

       Uri address = new

Uri(http://search.yahooapis.com/

ImageSearchService/V1/imageSearch”);

string appId = “YahooDemo”;

HttpWebRequest request =

 WebRequest.Create(address) as HttpWebRequest;

       // Set type to POST  

       request.Method = “POST”;

       request.ContentType = “application/x-www-form-urlencoded”;

       // Create the data we want to send  

       StringBuilder data = new StringBuilder();

       data.Append(“appid=” + HttpUtility.UrlEncode(appId));

       data.Append(“&query=” + HttpUtility.UrlEncode(query));

       // Create a byte array of the data we want to send  

byte[] byteData =

UTF8Encoding.UTF8.GetBytes(data.ToString());

       // Set the content length in the request headers  

       request.ContentLength = byteData.Length;

       // Write data  

       using (Stream postStream = request.GetRequestStream())

       {

              postStream.Write(byteData, 0, byteData.Length);

}

       // Get response

       using (HttpWebResponse response =

request.GetResponse() as HttpWebResponse)

       {

              // Get the response stream  

             StreamReader reader =

new StreamReader(response.GetResponseStream());

             XmlDocument xmlOutput = new XmlDocument();

             xmlOutput.LoadXml(reader.ReadToEnd());

             XmlNodeList resultsNodes =

xmlOutput.GetElementsByTagName(“Result”);

             return resultsNodes;

}

}

That’s it!  Note for real world use, you’ll need to replace that AppId with a real Yahoo Application Id.

Pros:

  • XML Output is standard, JSON optional.  Works like a snap for .NET usage.
  • Amazing support and community for the APIs.
  • A Search SDK exists for C# and VB.NET, though I didn’t use it.  That’d probably replace all of the coding above to a simple call or two.
  • You only need one Yahoo! Application ID per… application! (you’ll see why this is a pro in a minute).
  • Almost any language/framework has a Developer Center.

Cons:

  • It’s Yahoo.  I’m a Google fan myself (using Web Search, Google Mail, Google Docs, etc.), maybe this will change my mind and make this into a Pro as time goes on.

Google Developer APIs

Google’s been my Search of Choice for years now.  As I mentioned above, I use several of their services and have never had much of a problem.  In the results I get back from their search services, I tend to get what I’m looking for in the top ten or twenty, not the top 100 to 200 as I do with Yahoo and Live Search. With that in mind, their Developer Center is almost horrifying.  While AJAX and JavaScript are grand technologies, I had hoped for a bit of the same control as the Yahoo! solution provided—especially if I wanted to consume the information in non-web applications. 

[update 30 Oct 07: Google previously had a SOAP Search, but as of 5 December 2006, the SOAP Search is no longer available.  Bloody hell, why?! 

“Depending on your application, the AJAX Search API may be a better choice for you instead. It tends to be better suited for search-based web applications and supports additional features like Video, News, Maps, and Blog search results.

Okay, I’ll give you that, but what if you don’t want to use it in a web application?  *grumble*]

To provide an example of the AJAX Web Search, here’s what we have:

 

<html>
<head>
<title>Search Example</title>

<script type=”text/javascript”
  src=”http://www.google.com/jsapi?key=KEY&#8221; />
<script type=”text/javascript”> 

google.load(“search”, “1”);

function initialize()
{
 var searchControl = new google.search.SearchControl();
 searchControl.addSearcher(new google.search.WebSearch());
 searchControl.draw(document.getElementById(“searchcontrol”));
}

google.setOnLoadCallback(initialize);

</script>
<script type=”text/javascript”>

</script>

</head>
<body>
    <div id=”searchcontrol”></div>
  </body>
</html>

 

That code works just fine, but it doesn’t give me control of the UI or the results, it generates: Now, I did find the google-gdata project, a Google Data API for .NET—but apparently GData doesn’t include things like searches, only Claendars, Docs, and such.  Bleh. So, what could be done to wrap this up?  I could put the JavaScript into a custom control and intercept the text coming back into the element from the .Draw method, but ehh… beyond that, I’m interested to see how others are wrapping Google technologies into .NET applications—if you have, please post links and feedback!

 

Pros:

  • Development outside .NET or outside the OOP side of .NET, it’s pretty slick.
  • Creates a nice interface for the tools.

Cons:

  • You need a new application key for every service you use, for every site you create.  If your site consumes Search, AJAX Feed, and Maps, you need 3 keys.  Really a hassle.
  • Appears to be little or no language specific support outside of HTML and JavaScript for the API.  That’s fine, but wrappers would be nice too.
  • Google Web Toolkit is Java only. 😦

For now, both of these services still interest me and both are excellent examples of what could be done to mash up technologies into a modern web application—it all depends on what you need. For grins, I’m sure the “Microsoft” answer is to consume Live Services rather than the competition, but I’ve never had much luck using Live—anyone using it now?

Google’s Lost it’s Cookies

August 17, 2007 4 comments

Reading through the blogs and the notes attached to each Google “gadget,” it appears something has been happening in the background at Google and all that’s left are a few fingerprints and cookie crumbs.

As far as I understand, the gadgets use profile-specific “cookies” for authored gadgets (non-Google).  For example, things like the del.icio.us, Enhanced Bookmarks, and other cool plug-ins to the iGoogle homepage.

Well, earlier this week, something has gone astray.  I haven’t had del.icio.us bookmarks all week and today, my Enhanced Bookmarks… just vanished.  *twitch*

I like Google’s because I use gmail, google docs and really like having the translator (my workplace has 6 “official” languages, so I’m constantly translating UI elements and such) and wikipedia show up for quick reference.  I’d be a bit more inclined to MSN if I was a Hotmail user… but no.  But, on the other hand, I can’t deal with this unreliability… especially when it’s not something that I can back up.

So, I’m curious… what does everyone use for a “home page”? 

 

Categories: Google

Google joins the “let’s sue Microsoft!” party!

At first, when I saw the headline, I couldn’t quite grasp what business a search provider could have with suing a client/operating system maker.  Last I checked, Google kicked LiveSearch’s butt.  Well, it appears it has to do with their Desktop Search application.

Google’s allegations are under review by the Justice Department and state attorneys general who were parties to a consent decree that resolved the US government’s antitrust case against Microsoft in 2002.

Microsoft rejected Google’s allegation that the Vista desktop search violates the settlement.

“We don’t believe that this feature is covered by the consent decree or that it raises any antitrust issues,” Brad Smith, Microsoft’s general counsel, was quoted as saying.

A report on the latest allegations to the Washington federal court overseeing the case is due later this month and the judge, Colleen Kollar-Kotelly, “has shown frustration over Microsoft’s compliance with the settlement,” the Journal noted.

Google files antitrust complaints against Microsoft: report – Yahoo! News.

Now, I have to admit.  In Vista, I have the “instant” search turned off and use the search bar primarly as a run bar (you can type cmd, regedit, iexplore, outlook, whatever and it runs… neat stuff). I don’t (often) misplace my files as they’re on file servers… and I don’t really store anything on my local machine, even my email, which I use Google Mail (gmail) for—I have no need to constantly parse my hard drives for files.

But, if I WANT to, I could simply disable it using the Control Panel and install Google’s.  What’s so “blocking” about that?  Did I miss something or what?  When I install Vista, does it ask me if I want to install, feature-by-feature, every aspect of the operating system from a 3rd party?  Nope… thank God.  But, if I’m smart enough (read: an elementary school kid’s level of computer savvy), I can install those features I’m looking for if I’m not pleased with Microsoft’s version.

What’s next?  Are we going to sue Microsoft because we want to replace the Spell Check tool in Office and there isn’t an easy way to do it?

 

MSDN Really Slow Search?

The new “MSDN” has been a dog… a slow, very tired, somewhat early-days-of-summer dog.  The new layout is an upgrade, for sure, but the interface and moving page-to-page is extremely slow.  To top it off, today, I hit it up and ran a simple query (it’s a long day already and I just couldn’t remember some of the control property syntax).  So, rather than Google, I set my IE7 search bar to MSDN and searched there.

Results 1-50 of approximately 81 for: “Web User Control” +properties (15.3 seconds)

MSDN Enhanced Search.

15.3 seconds.  On the web, that is a LIFETIME and my mind has already moved on to another tab or window to do something else.  I ran it a few more times to see if it was caching or anything useful, and it kept taking LONGER and returning the same amount of results.  Wow.  What about Google?

Personalized Results 150 of about 17,300 for Web User Control” +properties. (0.19 seconds)

Google Search.

Nuff said.

Categories: Google

Creating Information From Data…

June 5, 2007 Comments off

I think, however, that simply calling the current school-age generation a “generation of editors” is a little too limiting. It’s true that today’s kids don’t have to hunt down kernels of information as if they’re ancient Cro-Magnon scrounging for roots and berries. Instead, it seems to be replacing those hunting-and-gathering skills with the ability to synthesize and combine information in ways that my own Baby Boomer mind can’t always grasp.

Are We Just Editors Now? by Loyd Case of ExtremeTech

This article from ExtermeTech’s Loyd Case caught my attention this morning.  He, as ironincally has he notes, is responding to Bill Harris’ article entitled “Information”.  In it, he notes how disecting information has changed through the generations.  Both authors are comparing times to those of their generation (mid-to-late 40’s to 50’s) and even that of my parents (70’s) in how information is acquired and decoded.

So if you were researching something, you’d have to pull out a rack in the card catalog according to the alphabetized subject and flip through the cards. If you got lucky, the title of a book or a brief description would point you in the right direction. Then you had to actually find the book, skim through it, and hope that you’d find some information.

I know what you’re thinking about now: you’ve got to be freaking kidding me.

Dubious Quality: Information by Bill Harris

I remember that.  I’m, in spite of the target audience, in my 20’s and I remember the card catalog (my small, rural school district was a bit late in adopting technology).  I even remember the dewey decimal system—inspite of all attempts to forget it.  But, I’m also part, I believe of this age of information mashup—using Google or whatever information source of choice, and finding bits and pieces of data here and there, applying logic and care (ala: not everything you read on the Internet is true—you’ve had this lecture, right?), and then turning that data into information for your purpose.

Now, looking forward and seeing what the youth of today are doing is astonishing.  Collaboration, sharing, information overload using MySpace, Facebook, YouTube, even here on WordPress.  The alpha site for Popfly is a great example of the current demand—taking dozens of information services and mixing and mashing them together to come up with a solution: a photo album that contains music referenced by keywords in each photo, an address book with photos from Facebook and a map using Maps, etc.

I do agree with Loyd’s assumption that these are not “editors”, as that, to a degree, implies that nothing new is being created; however, this generation advocates data and services as multi-purpose tools and excel at finding new ways to use data and turn it into information, not simply finding a source of reference and citing it in a book report.

 

Categories: Education, Family, Google, WordPress

Replacement for Omea found in Google?

March 5, 2007 Comments off

I was tormented most the weekend by being unable to access Omea at work (couldn’t RDP into the office) and found that I hate relying on client applications.  I dinked around with Google’s Reader and Groups and am pretty pleased.  Reader is especially nice, I love it—it’s fast, it can import my OPML lists, and it’s everywhere I go.  I did have a bit of a downer with Google Groups that I’m still attempting to work around—my MSDN account.  I have a specific email address I use on the microsoft.public.* groups and Google Groups forces me to use my Gmail account.  Hmm.

I’ll keep working with it—I like the tools and the flexibility; I just need to work through the current hassle regarding the email address.

Tags: , , ,

Googling for Fun and Profit

February 28, 2007 Comments off

Well, maybe just for fun.  I am constantly battling a culture at work of people who hate finding something on their own—especially if they can email and ask someone and forget about it.  I was raised to be a fisherman (teach a man to fish concept) and love that the Internet allows us such quick access to information.  I tend to search for something and end up researching (or at least bookmarking) a couple other things that I didn’t intend to…

So, with Google, and since I use Google Docs, Search, Mail, and a few other things, I checked out my history.  Trends entertain me a great deal, so it’s interesting to see my own trends.

I’m wondering what was up in March and May… do I get smarter or just less inquisitive during those months?

Wow, I search a lot.

Tags: , ,

Categories: Google