Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.net/C中用OAuth实现Yahoo BOSS v2时遇到问题#_C#_.net_Oauth_Yahoo Api - Fatal编程技术网

C# 在.net/C中用OAuth实现Yahoo BOSS v2时遇到问题#

C# 在.net/C中用OAuth实现Yahoo BOSS v2时遇到问题#,c#,.net,oauth,yahoo-api,C#,.net,Oauth,Yahoo Api,我一直在尝试使用Yahoo BOSS v2 api创建一个简单的搜索页面,但无法使OAuth正常工作。我有所有的密钥等,并在下载了OAuth的C#类,但我不断得到错误 我们尝试了以下方法: javascript函数构建一个yahoo boss查询字符串,然后导致 getYahoo(查询字符串,responseFunction) 这是背后的代码 [WebMethod] public static string getYahoo(string url) { String resu

我一直在尝试使用Yahoo BOSS v2 api创建一个简单的搜索页面,但无法使OAuth正常工作。我有所有的密钥等,并在下载了OAuth的C#类,但我不断得到错误

我们尝试了以下方法:

javascript函数构建一个yahoo boss查询字符串,然后导致 getYahoo(查询字符串,responseFunction)

这是背后的代码

[WebMethod]  
public static string getYahoo(string url)  
{  
    String result;  
    OAuthBase oauth = new OAuthBase();  
    Uri uri = new Uri("http://mysite.com");  
    string a, qstring = "";  
    string signature = oauth.GenerateSignature(uri, "-my consumer key-", "-my
    secret-", out a, out qstring);  
    url = url.Replace("{oauth}", qstring + "oauth_signature=" + signature);  
    WebResponse objResponse;  
    WebRequest objRequest = System.Net.HttpWebRequest.Create(url);  
    objResponse = objRequest.GetResponse();  
    using (StreamReader sr =
    new StreamReader(objResponse.GetResponseStream()))  
    {  
        result = sr.ReadToEnd();   
        sr.Close();
    }

    return result;
}
下面是我在oAuthBase类中的GenerateSignature方法:

public string GenerateSignature(Uri url, string consumerKey, string
    consumerSecret, out string normalizedUrl, out string
    normalizedRequestParameters)
{  
    normalizedUrl = null;  
    normalizedRequestParameters = null;  

    string signatureBase = GenerateSignatureBase(url, consumerKey,null
    ,null,null,GenerateTimeStamp(),GenerateNonce(), HMACSHA1SignatureType, out
    normalizedUrl, out normalizedRequestParameters);  

    HMACSHA1 hmacsha1 = new HMACSHA1();  
    hmacsha1.Key = Encoding.ASCII.GetBytes(string.Format("{0}&{1}",
    UrlEncode(consumerSecret), ""));  

    return GenerateSignatureUsingHash(signatureBase, hmacsha1);  

}  
但我们不断地发现错误:

Message: Sys.Net.WebServiceFailedException: The server method 'getYahoo' failed
with the following error: System.Net.WebException-- The remote server returned
an error: (401) Unauthorized.
Line: 6934
Char: 21
Code: 0
我希望这里有人能帮忙

您可以使用my或查看其源代码以使用BOSS v2。
您可以找到一个使用lib的示例。

您是否在ysearchboss@yahoogroups.com电子邮件列表?几天前,他们发布了一个工作示例(我没有检查),它是c。你想在这里发布吗?是的,路易斯,请在这里发布或在这里发布链接!谢谢-