Microsoft has an API for their Bing search engine that is accessible from Flex. This tutorial will show you how to use it.
Bing is Microsofts latest shot at the search giant Google, and by most accounts it has had a slow but steady uptake. And like any self respecting Web 2.0 application, Bing has an API that gives 3rd party developers access to its functionality. The API can be accessed either through JSON, XML or SOAP, and while all of the official documentation focuses on Microsoft languages like VB.NET and C#, any platform can make use of these web services. Here we will build a simple AIR application that uses Bing to perform a search.
The first decision you have to make is which of the three protocols to use. The as3corelib library provides convenient tools for JSON object conversion, and ActionScript supports XML as a native data type, but SOAP is the easiest protocol to use thanks to Flex Builders ability to import a WSDL web service.
You need to sign up for a Bing API Key, which you can do here.
Create a new Flex project. We will be creating an AIR application here, but the code is almost identical for a Flash web application. Click the Data->Import Web Service (WSDL.)... option.
Use the default source folder, and then enter the URL http://api.bing.net/search.wsdl?AppID=YourAppKeyHere&Version=2.2 as the WSDL URI.
Leave the rest of the default settings and finish the import procedure. This will create the classes required to interact with the Bing service.
The Bing API defines a class called Error, and another class called ArrayOfError that references the Error class. Unfortunately Flex already includes a class called Error, and when ArrayOfError is compiled it can't distinguish between the Bing Error class and the Flex one. This is fairly simple to fix by replacing all references to Error in the ArrayOfError class (located in src\net\bing\ArrayOfError.as) with net.bing.Error.
Now that the Bing API has been imported we can start using it. On your GUI add a TextInput for a question to be entered, a TextArea for the results to be displayed, and a Button to initiate the search.
Set the results TextArea to not be editable.
Set the Button to call the search function when it is clicked.