Commit 1a566f86 authored by nanahira's avatar nanahira

fix

parent 47e331f0
...@@ -68,7 +68,7 @@ public class MyCardHelper { ...@@ -68,7 +68,7 @@ public class MyCardHelper {
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode >= 400) if (response.StatusCode != HttpStatusCode.OK)
{ {
fail_reason = response.StatusDescription; fail_reason = response.StatusDescription;
return false; return false;
...@@ -98,18 +98,18 @@ public class MyCardHelper { ...@@ -98,18 +98,18 @@ public class MyCardHelper {
return null; return null;
} }
try { try {
string auth_str = Convert.ToBase64String(Encoding.UTF8.GetBytes(username + ":" + userid)); string auth_str = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(username + ":" + userid));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.mycard.moe/ygopro/match?locale=zh-CN&arena=" + match_type); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.mycard.moe/ygopro/match?locale=zh-CN&arena=" + match_type);
request.Method = "POST"; request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded"; request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("Authorization", "Basic " + auth_str); request.Headers.Add("Authorization", auth_str);
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode >= 400) if (response.StatusCode != HttpStatusCode.OK)
{ {
fail_reason = response.StatusDescription; fail_reason = response.StatusDescription;
return false; return null;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment