2013-02-15 41 views
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」

當我在地址欄

進入執行字符串請提供有效憑據。 OAuth oauth_problem =「OST_OAUTH_PARAMETER_ABSENT_ERROR」,realm =「yahooapis.com」正在運行,我認爲發生了身份驗證錯誤。但我不明白我在哪裏設置認證參數與API?在網址?但是如何?請幫助一個示例代碼。

+0

目前還不清楚你在問什麼。第二個鏈接是什麼? 「cooured」是什麼意思?你有什麼嘗試? – Jules 2013-02-15 06:34:56

回答

4

我認爲你需要添加授權標題與請求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調用。