Yesup
 

YGISAPI - Yamabay's Google Image Search API for VB/ASP Developers

Yamabay Google Search API Sample Result

I. What does YGISAPI do, and why supports VB/ASP?

Yamabay's Google Image Search API, or YGISAPI, is a COM/ActiveX which allows VB/ASP developers to incoporate Google's Image Search capability into their programs. Google does provide Search API, but no Image Search API available. There are quite a few Google Image Search API available on the Internet, but none supports Classic VB/ASP developers as COM/ActiveX.Yamabay's. YGISAPI runs on Windows 2000, XP, Windows 2003 with Microsoft.NET Framework 1.1 installed.

II. How to install YGISAPI ?

First of all, you can download the Yamabay YGISAPI here . In addition to YGISAPI, there are many other utilities you can download from here too.

This zip file contains not just the DLL. It has a sample working VB project and a sample working asp file showinfo.asp for your reference.

After download and unzip, you will find a dll called Google.API.ImageSearch_COM.dll . This is a .NET assembly, in order to make it COM/ActiveX, we will need to do the following two things:

Step one: register it to Global Assembly Cache. The command line is

gacutil /i Google.API.ImageSearch_COM.dll

Step two: make it available to COM/ActiveX. The command line is

regasm /tlb Google.API.ImageSearch_COM.dll

(The gacutil.exe and regasm.exe are usually located at: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 for Windows XP and 2003 Server. For general information about converting Net Assembly to ActiveX/COM please refer to: Convert .NET Assembly to ActiveX/COM. )

After you have successfully run this command, a file Google.API.ImageSearch_COM.tlb will be generated in the same folder as the DLL. You VB program will need to reference to this TLB file in order to use YGISAPI.

Your Ad Here

III The API of Yamabay's Google Image Search API

Before you can use YGISAPI, you need to Server.CreateObject in ASP, or New, in VB:

ASP: set SearchService = Server.CreateObject("Google.API.ImageSearch_COM.SearchService")

VB: Dim SearchService As New Google_API_ImageSearch_COM.SearchService

Then, there is only one API:

Set resp = SearchService.SearchImages(SearchQuery, StartPosition, ImagesRequired, NeedSimilarResults)

Where

SearchQuery is the Google Search String, like "ZiYi Zhang", "Catherine Zeta Jones". To make it more compatible, it  is a good idea to replace space by "+". So "Ziyi+Zhang" or "Catherine+Zeta+Zones".

StartPosition is an integer index, zero based, specifying the index of the first image you want to get. 0 is recommended.

ImagesRequired is an integer, specifing how many images you want to get from this query. Although no hard limitation, a number betwen 1 and 100 is recommended, considering we are using string to pass information back in YGIAPI.

NeedSimilarResults is of boolean type, specifying whether you'd like to get similar results.

resp is of type Google_API_ImageSearch_COM.SearchResponse.

Sample:

VB:

Dim resp As Google_API_ImageSearch_COM.SearchResponse

Set resp = SearchService.SearchImages("Ziyi Zhang", 0, 5, False)

ASP:

Dim resp

Set resp = SearchService.SearchImages("Ziyi Zhang", 0, 5, False)

Once you get the SearchResponse resp , the next thing is to get the results from the property of resp. There are two properties available

TotalResultsAvailable as Integer : number of total available images for you to retrieve.

SearchResultStr as String : a "strutured" string delimited by '!' for different images and '^' for different attributes of that image.

Below is a sample resp.SearchResultStr:

img1url1^400^600^130000^thumburl1^100^150!imgurl2^450^700^88811^thumb2^120^300!imgurl3^300^300^45000^thumburl3^100^120

Note that the VB developers can use Split (resp.SearchImages, '!') to get an array of Image Structure img, then for each of the Image Structure img, we can do Split(img, '^') to get the 7 attributes of the Image.

These 7 attributes are:

Index 0: Image URL

Index 1: Width of Image, in pixel. You will need to use CInt() to convert it to Integer. 

Index 2: Height of Image, in pixel. You will need to use CInt() to convert it to Integer. 

Index 3: Size of Image, in byte. You will need to use CInt() to convert it to Integer. 

Index 4: Thumbnail URL.

Index 5: Width of Thumbnail, in pixel. You will need to use CInt() to convert it to Integer.

Index 6: Height of Thumbnail, in pixel. You will need to use CInt() to convert it to Integer.

Sample Code to Enumerate these attributes:

Set resp = SearchService.SearchImages("Ziyi Zhang", 0, 5, False)

Debug.Print resp.TotalResultsAvailable t = Split(resp.SearchResultStr, "!")

For Each tt In t u = Split(tt, "^")

Debug.Print "Img URL:" & u(0)

Debug.Print "Img Width:" & u(1)

Debug.Print "Img Height:" & u(2)

Debug.Print "Img Size:" & u(3)

Debug.Print "Thumb URL:" & u(4)

Debug.Print "Thumb Width:" & u(5)

Debug.Print "Thumb Height:" & u(6)

Next 

Anti Spam WinASP Web2Image Skype Gateway Dashboard Chart OE6 COM/ActiveX
Copyright © 2000-2006 YamaBay. All rights reserved.  Privacy Policy