Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro2
Commits
c97a4a8d
Commit
c97a4a8d
authored
May 14, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewind back to www
parent
a44eaa69
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
32 deletions
+16
-32
Assets/SibylSystem/selectServer/MyCardHelper.cs
Assets/SibylSystem/selectServer/MyCardHelper.cs
+16
-32
No files found.
Assets/SibylSystem/selectServer/MyCardHelper.cs
View file @
c97a4a8d
using
UnityEngine
;
using
UnityEngine.Networking
;
using
System
;
using
System.Text
;
using
System.Collections.Generic
;
...
...
@@ -56,28 +55,21 @@ public class MyCardHelper : MonoBehaviour {
try
{
LoginRequest
data
=
new
LoginRequest
(
name
,
password
);
string
data_str
=
data
.
Stringify
();
UnityWebRequest
www
=
UnityWebRequest
.
Post
(
"https://api.moecube.com/accounts/signin"
,
data_str
);
www
.
SetRequestHeader
(
"Content-Type"
,
"application/json"
);
www
.
SendWebRequest
();
Dictionary
<
String
,
String
>
header_list
=
new
Dictionary
<
String
,
String
>();
header_list
.
Add
(
"Content-Type"
,
"application/json"
);
byte
[]
data_bytes
=
Encoding
.
UTF8
.
GetBytes
(
data_str
);
WWW
www
=
new
WWW
(
"https://api.moecube.com/accounts/signin"
,
data_bytes
,
header_list
);
while
(!
www
.
isDone
)
{
if
(
www
.
isNetworkError
||
www
.
isHttpError
)
if
(
Application
.
internetReachability
==
NetworkReachability
.
NotReachable
||
!
string
.
IsNullOrEmpty
(
www
.
error
)
)
{
fail_reason
=
www
.
error
;
return
false
;
}
}
if
(
www
.
responseCode
>=
400
)
{
fail_reason
=
"Login failed"
;
return
false
;
}
else
{
string
result
=
www
.
downloadHandler
.
text
;
LoginObject
result_object
=
JsonUtility
.
FromJson
<
LoginObject
>(
result
);
username
=
result_object
.
user
.
username
;
userid
=
result_object
.
user
.
id
;
}
string
result
=
www
.
text
;
LoginObject
result_object
=
JsonUtility
.
FromJson
<
LoginObject
>(
result
);
username
=
result_object
.
user
.
username
;
userid
=
result_object
.
user
.
id
;
}
catch
(
Exception
e
)
{
fail_reason
=
e
.
Message
;
return
false
;
...
...
@@ -93,27 +85,19 @@ public class MyCardHelper : MonoBehaviour {
}
try
{
string
auth_str
=
"Basic "
+
Convert
.
ToBase64String
(
Encoding
.
UTF8
.
GetBytes
(
username
+
":"
+
userid
));
UnityWebRequest
www
=
UnityWebRequest
.
Post
(
"https://api.mycard.moe/ygopro/match?locale=zh-CN&arena="
+
match_type
,
new
WWWForm
()
);
www
.
SetRequestHeader
(
"Authorization"
,
auth_str
);
www
.
SendWebRequest
(
);
Dictionary
<
String
,
String
>
header_list
=
new
Dictionary
<
String
,
String
>(
);
header_list
.
Add
(
"Authorization"
,
auth_str
);
WWW
www
=
new
WWW
(
"https://api.mycard.moe/ygopro/match?locale=zh-CN&arena="
+
match_type
,
new
WWWForm
(),
header_list
);
while
(!
www
.
isDone
)
{
if
(
www
.
isNetworkError
||
www
.
isHttpError
)
if
(
Application
.
internetReachability
==
NetworkReachability
.
NotReachable
||
!
string
.
IsNullOrEmpty
(
www
.
error
)
)
{
fail_reason
=
www
.
error
;
return
null
;
}
}
if
(
www
.
responseCode
>=
400
)
{
fail_reason
=
"Match failed"
;
return
null
;
}
else
{
string
result
=
www
.
downloadHandler
.
text
;
MatchObject
result_object
=
JsonUtility
.
FromJson
<
MatchObject
>(
result
);
ret
=
result_object
.
password
;
}
string
result
=
www
.
text
;
MatchObject
result_object
=
JsonUtility
.
FromJson
<
MatchObject
>(
result
);
ret
=
result_object
.
password
;
}
catch
(
Exception
e
)
{
fail_reason
=
e
.
Message
;
return
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment