Bing, Misc, References, Scripting
comments 3

Bing developer APIs – A VBScript demonstration

Bing – the most talked about and the most innovative decision engine. There is lot of talk on the Internet about this already. I am not going to write a review on that here. I want to show how developers can use — using a simple VBScript — the power of Bing in their applications.

Bing API offers open, flexible options for building or enhancing your site or applications. Developing an application with the new API is straightforward: Choose a SourceType (or SourceTypes—Search, Spell, Translation, etc), choose an output protocol (JSON, SOAP, or XML) and then customize according to your needs.

Before getting started with BING APIs, you need to get a APPID from Bing. For more information on how to create a appid, refer to http://www.bing.com/developers. You will have to login using your live ID and create an APPID for the application you are creating. There is a nice API basics guide to get you started. Now, to the more interesting stuff..!

[Code][download id=”4″ format=”4″][/Code]

First example: Spell check

[Code lang=”vb”]

Set http = CreateObject(“Microsoft.XmlHttp”)
strURL = “http://api.search.live.net/xml.aspx?AppId=Your_APPID&Query=coffee&Sources=Spell”
http.open “GET”, strURL, FALSE
http.send “”
WScript.Echo http.responseXML.xml
[/Code]

In the above example, replace Your_APPID with your spell checker appid. When you run this VBScript, you will see a XML output similar to the below one.

Spell check XML

As you can see, I gave “Coffe” as my search term to the Spell Checker API and I get a response with the corrected spelling. In this case, there is just one possibility. There could be an instance where you may see multiple values. It is up to you to handle this XML output.

Let us see another example.

Second example: Translation

[Code lang=”vb”]
Set http = CreateObject(“Microsoft.XmlHttp”)
strURL=”http://api.search.live.net/xml.aspx?AppId=Your_APPID&Query=Hello, world&Sources=Translation&Version=2.2&
Translation.SourceLanguage=en&Translation.TargetLanguage=es”
http.open “GET”, strURL, FALSE
http.send “”
WScript.Echo http.responseXML.xml
[/Code]

Again, when you run this,

Bing Translation

That is it. Isn’t that simple. Of course, other programming languages like C# or PHP provide much more power and you can do various things than just displaying the XML output. My intention is only to show how simple it is to access Bing APIs from your application. In fact, we can modify these VBScripts to do something more such as list all possible spellings or insert the translated text in to a web form, etc. There is no end to the possibilities. I will try and put some more sample code whenever possible.

Anyway, I will leave this now to you to explore and experiment
Filed under: Bing, Misc, References, Scripting

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.