如何从C#为Pinnacle API下注请求?
有人可以帮忙解决一些小例子吗?
http://www.pinnacle.com/en/api/manual - 这是巅峰api文档
从该文档中没有问题我可以获得总数和其他赔率的所有团队,或者我可以获得团队名称。
以下是通过C#和pinnacle API获取某些类型运动的所有赔率的代码示例:
/// <summary>
/// This function get events with their totals
/// </summary>
/// <returns></returns>
protected virtual async Task<HttpWebResponse> GetAllTotalsAsync(string userLogin, string userPass)
{
var request = (HttpWebRequest)WebRequest.Create("https://api.pinnaclesports.com/v1/odds?sportid=" + (int)_sportType);
string credentials = $"{userLogin}:{userPass}";
byte[] bytes = Encoding.UTF8.GetBytes(credentials);
string base64 = Convert.ToBase64String(bytes);
string authorization = String.Concat("Basic ", base64);
request.Headers.Add("Authorization", authorization);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
request.Method = "GET";
request.Accept = "application/json";
request.ContentType = "application/json; charset=utf-8";
return (HttpWebResponse)await request.GetResponseAsync().ConfigureAwait(false);
}
稍后从HttpWebResponse我们可以获得JSON输出
var totalResp = await GetAllTotalsAsync(userLogin, userPass).ConfigureAwait(false);
var sportEvents = (JsonObject)JsonValue.Load(totalResp.GetResponseStream());
在sportEvents中,我们拥有包含所有数据的JSON。
那么,任何人都可以通过使用C#laguage来帮助我通过Pinnacle API下注吗?