0

我正在开发“ http://developer.yahoo.com/yql/console/ ”网站。 http://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20social.profile%20where%20guid='ZGVG52ZDAYGCZRFF4VBA5L6ICY'

当我在地址栏中输入执行的字符串时

请提供有效的凭据。OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com" 我认为发生了身份验证错误。但我不明白我在哪里使用 api 设置身份验证参数?在网址中?但如何?请帮助提供示例代码。

4

1 回答 1

4

我认为您需要添加 Authorization 标头,并将请求 Uri 作为标头。像这样的东西

        string headerString = "Authorization: OAuth realm=Your Oauth realm&" +
                            "oauth_timestamp= xxxxxxxx&oauth_nonce=your value&,"+
                            "oauth_version=1.0&oauth_signature_method=HMAC-SHA1&"+
                                "oauth_consumer_key=your key&,oauth_token=your token&"+
                                    "oauth_signature=your signature";

        var req = (HttpWebRequest)WebRequest.Create("requsting uri");
        req.ContentType = "application/xml";
        req.Method = "POST";
        req.Headers.Add(headerString);

        HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
        var sr = new StreamReader(resp.GetResponseStream());
        string response = sr.ReadToEnd().Trim();

在这里,我假设您正在拨打 POST 电话。

于 2013-02-15T06:41:43.553 回答