我想從雅虎拉細節!使用OAuth2.0的Fantasy Sports API。我得到了access_token
使用YQL進行查詢。我的代碼無法查詢Yahoo! Fantasy體育API
using (var client = new System.Net.WebClient())
{
client.Headers.Add("Authorization", "Bearer " + response.access_token);
var query = "select%20*%20from%20fantasysports.games%20where%20game_key%3D'nfl'";
Response.Write(query);
var url = String.Format("https://query.yahooapis.com/v1/yql?q={0}&format=json&diagnostics=true&callback=", query);
output = client.DownloadString(url);
}
我的回答
{
"query": {
"count": 0,
"created": "2015-09-27T17:39:48Z",
"lang": "en-US",
"diagnostics": {
"publiclyCallable": "true",
"url": {
"execution-start-time": "4",
"execution-stop-time": "137",
"execution-time": "133",
"http-status-code": "401",
"http-status-message": "Authorization Required",
"content": "http://fantasysports.yahooapis.com/fantasy/v2/games;game_keys=nfl"
},
"user-time": "138",
"service-time": "133",
"build-version": "0.2.240"
},
"results": null
}
}
我正在一個需要授權狀態消息。
我認爲它必須做我的請求標題。有人能幫助我理解爲什麼我的請求在這裏被拒絕嗎?
'Response.Write(query);'看起來很狡猾。 –
@RichardSchneider:沒有其他更簡單的方式雅虎!不會讓我在本地測試Fantasy Sports API – naveen
@naveen,你有沒有得到這個工作,所以你可以從雅虎體育使用C#拉動公共數據?我正在努力,但發現它非常困難。我試圖運行這個YQL命令:select * from fantasysports.players其中game_key = 371,這應該不是我使用的RESTful命令:https://query.yahooapis.com/v1/public/yql?q=select %20 *%20 from%20fantasysports.players%20where%20game_key%3D371&diagnostics = true到目前爲止,您的帖子在這裏似乎是最有前途的,但我覺得你沒有列出你的整個代碼,只有片段,所以我不知道如何繼續 – dave317