Updated for breaking api change
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user