我一直在尝试私有查询的YQL。
我正在使用yahoo开发者网络的示例代码。 https://developer.yahoo.com/boss/search/boss_api_guide/codeexamples.html#oauth_csharp
代码如下所示。
class Program
{
static void Main(string[] args)
{
string consumerKey = "dj0yJmk9SzhxdHFrY0pHOTZ1JmQ9WVdrOWRVTTBOM1JhTkRRbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD01Ng--";
string consumerSecret = "34fd168eb4a91cd4c5cb2f9ec60e4ed74b278f00";
var uri = new Uri("http://query.yahooapis.com/v1/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AAPL%22)&env=store://datatables.org/alltableswithkeys");
string url, param;
var oAuth = new OAuthBase();
var nonce = oAuth.GenerateNonce();
var timeStamp = oAuth.GenerateTimeStamp();
var signature = oAuth.GenerateSignature(uri, consumerKey,
consumerSecret, string.Empty, string.Empty, "GET", timeStamp, nonce,
OAuthBase.SignatureTypes.HMACSHA1, out url, out param);
using (WebRequest.Create(string.Format("{0}?{1}&oauth_signature={2}",
url, param, signature)).GetResponse()) { }
}
}
它得到了遵守,但是当我执行它时,给了我运行时异常。
远程服务器返回错误:(401)未经授权。