Problem with Yahoo Sports API

I am trying to set up a simple application that consumes the Yahoo Fantasy sports API and allows queries through YQL.

class Program { static void Main(string[] args) { string yql = "select * from fantasysports.games where game_key in ('268')"; //var xml = QueryYahoo(yql); // Console.Write(xml.InnerText); string consumerKey = "--my key--"; string consumerSecret = "--my secret--"; var xml = QueryYahoo(yql, consumerKey, consumerSecret); Console.Write(xml.InnerText); } private static XmlDocument QueryYahoo(string yql) { string url = "http://query.yahooapis.com/v1/public/yql?format=xml&diagnostics=false&q=" + Uri.EscapeUriString(yql); var req = System.Net.HttpWebRequest.Create(url); var xml = new XmlDocument(); using (var res = req.GetResponse().GetResponseStream()) { xml.Load(res); } return xml; } private static XmlDocument QueryYahoo(string yql, string consumerKey, string consumerSecret) { string url = "http://query.yahooapis.com/v1/yql?format=xml&diagnostics=true&q=" + Uri.EscapeUriString(yql); url = OAuth.GetUrl(url, consumerKey, consumerSecret); var req = System.Net.HttpWebRequest.Create(url); var xml = new XmlDocument(); using (var res = req.GetResponse().GetResponseStream()) { xml.Load(res); } return xml; } 

There are some hidden ones here, I have a custom class to make url ok for Yahoo API. Here is the url structure returned by the OAuth.GetUrl () method

http: // query % 20% 28% 27268% 27% 29 & oauth_signature = NYKIbhjoirJwB6ADxVq5DOgLW1w% 3D

With this, I always seem to get an Authentication Error. Fantasysports.games table requires a higher level of security than expected, you have provided an APP, but at least USER is expected

I'm not sure what this means, I pass my auth information to the api, but it seems to me that I need more permissions. Does anyone have a working example of this. If necessary, I can provide the code to the GetUrl method, but this is more or less a copy from here

http://andy.edinborough.org/Getting-Started-with-Yahoo-and-OAuth

Let me know if you have any questions. Thanks!

+6
source share
1 answer

I could not get it to work using YQL, but I was able to get the player data and the project result, etc., directly using the APIs https://fantasysports.yahooapis.com/fantasy/v2/

eg. To get NFL David Johnson information:

GET / fantasy / v2 / players; player_keys = 371.p.28474 HTTP / 1.1

Host: fantasysports.yahooapis.com

Authorization: Bearer [[Base64 encoded ClientId: Secret]]

Content-Type: application / json

0
source

Source: https://habr.com/ru/post/911694/


All Articles