我试图通过YAHOO BOSS搜索API获取搜索结果。出于某种原因,我得到错误 - "远程服务器返回错误:(403)禁止。"。起初我以为是因为我没有添加付款方式,但即使添加后我也会得到同样的错误。
这是我的代码(在C#中):
var uri = new Uri("https://yboss.yahooapis.com/ysearch/web?callback=json2&q=flu");
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);
WebRequest request = WebRequest.Create(string.Format("{0}?{1}&oauth_signature={2}",url, param, signature));
using (WebResponse res = request.GetResponse())
{
string results = res.ToString();
}