07-live search 2.0

Post on 08-Jun-2015

127 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Live Services Jumpstart

TRANSCRIPT

Live ServicesSynchronizing Life

Microsoft Live Search 2.0

Live ServicesSynchronizing LifeAgenda

• Why use Live Search 2.0?• Benefits• Where do you start?

Live ServicesSynchronizing LifeWhy Live Search 2.0?

• Power of Live Search• Flexible ad serving• New content types – Increase traffic– Increase customer engagement

• Analysis Tools– Provide business intelligence– Customer insights

Live ServicesSynchronizing LifeBenefits

• Understand keyword performance data• Increase reach and relevance– Customizable search

• Monetize your site with ads• Access to:– News–Weather–Maps– Spelling– Instant answers

• Silverlight support

Live ServicesSynchronizing LifeProgramming Interfaces

• HTTP– XML– JSON– Query parameters (AppID, query, sources)

• SOAP• RSS

Live ServicesSynchronizing LifeLive Search Sources

Source DescriptionWeb Searches for Web contentImage Searches for images on the webNews Searches news storiesInstantanswer Searches Microsoft Encarta onlineSpell Searches Microsoft Encarta

dictionaryPhonebook Searches phonebook entriesrelatedsearch Returns the query strings most

similar to yours

Live ServicesSynchronizing LifeGetting an API key

• Go to http://search.live.com/developers

• Sign in with your Windows Live ID• Create a new AppID

Live ServicesSynchronizing Life

Using HTTP

8

Live ServicesSynchronizing LifeTypical HTTP Request

http://api.search.live.net/xml.aspx?Appid=<AppID>&query=sushi&sources=web+image+news

• Specify XML or JSON• Use your AppID• Pass in the query text• Specify the sources to search

That’s it!

Live ServicesSynchronizing Life

Typical HTTP Requests

Demo

Live ServicesSynchronizing LifeUsing XML

Live ServicesSynchronizing LifePaging

• Query string parameters– Offset– CountPrefix both with the source

• Example:– http://api.search.live.net/xml.aspx?

Appid=C8AA0270C8F5940FA2AA96C1048F401ED4DA0494&query=sushi&sources=web+image&web.count=10&web.offset=50&image.count=50&image.offset=100

Live ServicesSynchronizing LifeXML Results

Live ServicesSynchronizing Life

Using .NET

14

Live ServicesSynchronizing LifeXML API from .NET

string url ="http://api.search.live.net/xml.aspx?

Appid={0}&sources={1}&query={2}";

string completeUri = String.Format(url, API_KEY, "image", "sushi");

HttpWebRequest webRequest = null;webRequest =

(HttpWebRequest)WebRequest.Create(completeUri);

HttpWebResponse webResponse = null;webResponse =

(HttpWebResponse)webRequest.GetResponse();

Live ServicesSynchronizing LifeProcessing XML API image

XDocument data = XDocument.Load(xmlReader);IEnumerable<XNode> nodes = null;nodes = data.Descendants(XName.Get("Results", IMAGE_NS)).Nodes();if (nodes.Count() > 0){ var results = from uris in nodes select new LiveSearchResultImage { URI = ((XElement)uris).Element(XName.Get("Url", IMAGE_NS)).Value, Title = ((XElement)uris).Element(XName.Get("Title", IMAGE_NS)).Value, ThumbnailURI = ((XElement)uris).Element(XName.Get("Thumbnail",

IMAGE_NS)).Value, }; return results;

Live ServicesSynchronizing LifeJSON Results

JSON serialized response:"SearchResponse":{ "Version":"2.0","Query":{"SearchTerms":"sushi"},"Web":{ "Total":15000000,"Offset":

0,"Results":[{ "Title":"Sushi - Wikipedia, the free

encyclopedia","Description":"InJapanese cuisine, sushi (!!, !, !, sushi?) is vinegared

rice, usuallytopped with other ingredients, including fish (cooked or

uncooked) andvegetables.","Url":"http:\/\/en.wikipedia.org\/wiki\/

Sushi","DisplayUrl":"http:\/\/en.wikipedia.org\/wiki\/

Sushi","DateTime":"2008-06-09T06:42:34Z"}]}} /* pageview_candidate */}

Live ServicesSynchronizing Life

JSON Query

Demo

18

Live ServicesSynchronizing Life

Live Search 2.0 SOAP APIs

Live ServicesSynchronizing Life.NET code using SOAP

LiveSearchPortTypeClient soapClient = new LiveSearchPortTypeClient();

SearchRequest request = new SearchRequest();request.AppId = API_KEY;request.Sources = new SourceType[] { SourceType.Image };request.Query = query;SearchResponse response = soapClient.Search(request);if (response.Image != null && response.Image.Results.Count()

> 0){ var results = from uris in response.Image.Results select new LiveSearchResultImage { URI = uris.Url, Title = uris.Title, ThumbnailURI = uris.Thumbnail.Url, }; return results;

Live ServicesSynchronizing Life

ASP.NET Demo

Demo

21

Live ServicesSynchronizing Life

Silverlight

Live ServicesSynchronizing LifeSilverlight

• Create rich Search apps• Live Search 2.0 publishes a crossdomain.xml

policy file – http://api.search.live.net/crossdomain.xml– Allows Search 2.0 API from Silverlight

• APIs are the same as .NET– HTTP XML or SOAP

• Also has a JSON parsing object model• APIs are asynchronous

Live ServicesSynchronizing LifeSilverlight Sample

WebClient wc = new WebClient();wc.OpenReadCompleted += newOpenReadCompletedEventHandler(wc_OpenReadCompleted);item.CurrentQuery = p;item.Uri =new Uri(String.Format(_baseURI, API_KEY, "image", "sushi"));wc.OpenReadAsync(item.Uri, item);

void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e){ Stream streamResult = e.Result; XDocument xd = XDocument.Load(XmlReader.Create(streamResult)); // use the Xdocument

}

WebClient callback

Setup callback and make query

Live ServicesSynchronizing Life

Silverlight

Demo

25

Live ServicesSynchronizing Life

Live Search 2.0 Ad Source

Live ServicesSynchronizing LifeAd Source

• Opt into Ad Center• Integrate ads using the XML or JSON APIs

Query String DescriptionAd.AdUnitId Your adCenter Unit IDAd.PropertyId Your adCenter Property IDAd.Pagenumber The page number requestedAd.SBadCount Number of sidebar ads requestedAd.MLadCount Number of mainline ads requested

Live ServicesSynchronizing LifeAd Source

Live ServicesSynchronizing Life

RSS

Live ServicesSynchronizing LifeRSS

• Does not require AppID http://api.search.live.com/rss.aspx?

source=web&query=sushi+los%20angeles

• View in any RSS reader

Live ServicesSynchronizing LifeSubscribe to the Feed

Live ServicesSynchronizing LifeSummary

• Embed custom search into apps• Retrieve different sources• Use XML or JSON results• Use SOAP

Live ServicesSynchronizing Life

Discussion

Questions?

Live ServicesSynchronizing Life

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date

of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

top related