Updated for breaking api change

master
exsersewo 6 years ago
parent e3d6cbba3f
commit 2217762423
  1. 4
      SysEx.Net/Client.cs
  2. 2
      SysEx.Net/SysEx.Net.csproj
  3. 23
      SysEx.Net/WebRequest.cs

@ -71,8 +71,8 @@ namespace SysEx.Net
public async Task<string> GetWeebActionGifAsync(GifType type)
{
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/actions/?action=" + type.ToString().ToLowerInvariant()));
return resp;
var resp = await WebRequest.GetRedirectUriAsync(new Uri("https://api.systemexit.co.uk/actions/?action=" + type.ToString().ToLowerInvariant()));
return resp.OriginalString;
}
public async Task<string> GetWeebReactionGifAsync()

@ -15,7 +15,7 @@
<NeutralLanguage>en-GB</NeutralLanguage>
<RepositoryType>Library</RepositoryType>
<PackageLicenseUrl>https://github.com/exsersewo/SysEx.Net/blob/master/LICENSE</PackageLicenseUrl>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

@ -45,5 +45,28 @@ namespace SysEx.Net
return null;
}
}
public static async Task<Uri> GetRedirectUriAsync(Uri url)
{
try
{
var client = CreateWebRequest(url);
var resp = (HttpWebResponse)(await client.GetResponseAsync());
if (resp.StatusCode == (HttpStatusCode.OK | HttpStatusCode.Redirect))
{
var uri = resp.ResponseUri;
resp.Dispose();
client.Abort();
return uri;
}
resp.Dispose();
client.Abort();
return null;
}
catch
{
return null;
}
}
}
}

Loading…
Cancel
Save