【发布时间】:2009-02-02 13:04:00
【问题描述】:
我想用 C# 将 yahoo search api 集成到我在 asp.net 中的 Web 应用程序中。 我不知道怎么调用yahoo api。
【问题讨论】:
标签: asp.net web-services
我想用 C# 将 yahoo search api 集成到我在 asp.net 中的 Web 应用程序中。 我不知道怎么调用yahoo api。
【问题讨论】:
标签: asp.net web-services
string AppId = "foo";
string Query = "stackoverflow";
int NumResults = 10;
WebClient webClient = new WebClient();
string request = string.Format(
"http://search.yahooapis.com/WebSearchService/V1/webSearch?appid={0}&query={1}&results={2}"
, AppId
, Query
, NumResults);
byte[] response = webClient.DownloadData(request);
string responseXML = System.Text.UTF8Encoding.UTF8.GetString(response);
Console.WriteLine(responseXML);
【讨论】:
我不确定它是否仍然有效,但几年前我为此编写了一个 C# 和 VB.Net 包装器。雅虎甚至将它包含在他们的示例代码中。您可以从my site 下载它。基本上,您在从 Yahoo 的开发人员网站获得的 XML 架构上使用 XSD.Exe,然后将您的 Web 请求的结果反序列化为 XSD.exe 生成的对象。
【讨论】: