Updated for breaking api change

This commit is contained in:
2018-08-14 20:00:47 +01:00
parent e3d6cbba3f
commit 2217762423
3 changed files with 26 additions and 3 deletions

View File

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

View File

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

View File

@@ -45,5 +45,28 @@ namespace SysEx.Net
return null; 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;
}
}
} }
} }