Developers can use different functions by calling Web SDK when get into SG Game SDK. This document details the whole process of how to get into the client. It's important for you to read through and understand the document before starting development.
API Host URL: https://gameapi.smartgamesltd.com/.
GET POST /initDescription
You need to call init
function once before any other functions.
https://gameapi.smartgamesltd.com/init?gamekey=my_gamekey&appsecret=my_appsecret&channel=my_channel&version=sgsdk_version&versionname=app_version_name&versioncode=app_version_code&deviceid=my_device_id&useweb=trueParameters
gamekey | Your developer identification. You can obtain it through SG Developer console. |
appsecret | You can obtain it through SG Developer console. |
channel | The channel of your App. (Please refer to Channel List table) |
version |
SGSDK Version is 1002 now.
|
versionname | Version name when building app. Android is versionName. iOS is Version. Unity is Version. |
versioncode | Version code when building app. Android is versionCode. iOS is Build. Unity is Bundle Version Code. |
deviceid | ID of device. |
useweb | useweb=true Login by using browser or web view for. useweb=false Login by using android sdk or ios sdk. |
{"Code": xxx, "Message": "ok"}
.
Some API functions don't return data directly, instead they launch web pages. When developing app with these functions, follow the steps below to get the result data.
GetResult()
.init
function, beside normal response result, it will return a [Set-Cookie] value in response header.
you need to save the cookie value and pass it in in consecutive API calls.
webViewCookie.put("Cookie", response.headers.get("Set-Cookie"));
All response is in JSON format. Ex: {"Code": 101, "Message": "ok"}
.
API | Code | Message |
---|---|---|
General Error Code | 30 | Not init yet. |
31 | Account not found. | |
32 | Not login yet. | |
33 | DB error. | |
41 | Close web page. | |
init | 101 | ok |
102 | Post data error. | |
103 | Game not found. | |
104 | App secret error. | |
105 | Channel error. | |
106 | Version error. Please upgrade SG SDK. | |
login | 201 | ok |
202 | Reset password. | |
203 | Account or password error. | |
204 | Login by Wechat error. | |
205 | Login by wechat. | |
210 | WeChat auth ok. | |
211 | WeChat auth denied. | |
212 | WeChat user cancel. | |
213 | WeChat invalid code. | |
214 | WeChat get token ok. | |
215 | WeChat get user's info ok. | |
251 | Login OpenID bad. | |
252 | Not install SG plugin. | |
253 | SG plugin error. | |
254 | Not install WeChat. | |
255 | Login sequence ended. | |
signup | 301 | ok |
302 | Please enter confirm code. | |
303 | Please confirm password. | |
304 | Length of password have to longer than 5. | |
305 | This account has been used. | |
306 | No confirm code. | |
307 | Confirm code over time. | |
308 | Confirm code error. | |
309 | Account error. | |
310 | Send confirm code success. | |
confirm-code | 401 | ok |
402 | This phone number has already been registered. | |
forgot-password | 501 | ok |
change-password | 601 | ok |
602 | Please confirm new password. | |
603 | Length of password have to longer than 5. | |
604 | Password error. | |
reset-password | 701 | ok |
702 | Post data error. | |
703 | Reset password disabled. | |
704 | Please confirm password. | |
705 | Can not reset password. | |
706 | Password error. | |
my-kid | 801 | ok |
802 | Please fill all field. | |
806 | Index error. | |
verifysession | 901 | ok |
902 | Try error. | |
903 | Post data error. | |
904 | Game not found. | |
905 | Signature error. | |
loginbytoken | 1001 | ok |
1002 | No token. | |
1003 | Failed to authenticate token. | |
pay | 1101 | ok |
1102 | Try error. | |
1103 | Payment data error. | |
1104 | Order exists. | |
1105 | Send to U8 error. | |
1106 | Receive from U8 error | |
1107 | Payment callback from U8 failure. | |
1108 | Waiting for notify. | |
1109 | Illegal receipt. | |
1110 | Payment callback from game server failure. | |
1111 | Send to game server error. | |
WeChat Payment | 1120 | WeChat paid success. |
1121 | WeChat prepare order ok. | |
1122 | WeChat prepare order error. | |
1123 | WeChat prepare order fail. | |
1124 | Post payment response empty. | |
1126 | WeChat paid fail. | |
1127 | WeChat sign error. | |
1128 | SG plugin is installing. | |
ios in-app purchase | 1130 | IAP not init yet. |
1131 | IAP init ok. | |
1132 | Can not perform IAP. | |
1133 | There are no products. | |
1134 | Invalid product IDs. | |
1135 | Product id not found. | |
1136 | Purchase successful. | |
1137 | Purchase failed. | |
1138 | Unknown purchase state. | |
1139 | Get receipt failed. | |
1140 | AppStore nothing to restore. | |
1141 | Purchase restore successful. | |
1142 | Purchasing... | |
Google In App Purchase | 1151 | Google IAP: init successful. |
1152 | Google IAP: init error. | |
1161 | Google IAP: subscribe successful. | |
1162 | Google IAP: subscribe failed. | |
1171 | Google IAP: purchase successful. | |
1172 | Google IAP: purchase failed. | |
1173 | Google IAP: consume successful. | |
1174 | Google IAP: consume failed. | |
1180 | Google IAP: nothing to restore. | |
1181 | Google IAP: purchase restored: {product SKU} | |
1190 | Android SDK payment channel error. | |
getorder | 1201 | ok |
1202 | Try error. | |
1203 | Post data error. | |
1204 | Game not found. | |
1205 | Signature error. | |
1206 | Order not found. | |
gamestart | 1301 | ok |
gamestop | 1401 | ok |
1402 | Not call game start yet. | |
select-kid | 1501 | ok |
1502 | Index error. | |
logout | 1601 | ok |
change-language | 1701 | ok |
my-account | 1801 | ok |
1802 | Post data error. | |
1803 | Password error. | |
1804 | Account binding error. | |
1805 | No confirm code. | |
1806 | Confirm code expired. | |
1807 | Confirm code error. | |
log-screen | 1901 | ok |
1902 | Post data error. | |
log-event | 2001 | ok |
2002 | Post data error. | |
sgeye-log-event | 2101 | ok |
2102 | Post data error. | |
feedback | 2201 | ok |
2202 | Please login first. | |
2203 | Post data error. | |
parental-lock | 2401 | ok |
iOS SDK Error | 8000 | Javascript call GetResult() error. |
8001 | JSON decode error. | |
8002 | Http response try error. | |
8003 | Http response parse error. | |
8004 | Get open id ok. | |
Anroid SDK Error | 9900 | Get manifest meta data Error. |
9901 | Anroid SDK init Error. | |
9904 | Outside web start error. | |
9905 | Web activity start error. | |
9906 | Web view create error. | |
9907 | Page load error. | |
9910 | WebAPI Call Error. | |
9920 | WebAPI Response Data Error. | |
Unity Plugin Error | 9930 | Unity SDK call error. |
9931 | Payment channel error. | |
9932 | Unity listener callback error |
Here are the response objects used in SGSDK. Please follow the pascal case definition.
property | type | desciption |
---|---|---|
Code | integer | Return code. |
Message | string | Return message. |
Data | class |
Return data. Based on different situation, data might be NULL or an object. |
property | type | desciption |
---|---|---|
Account | string | SG Member account name. |
OpenID | string | SG member ID. |
WeChatID | string | Get it when login by WeChat. |
FBID | string | Get it when login by Facebook. |
Token | string | Token of the after login, expired in 7 days. |
CreateTime | DateTime | Created time. |
LoginTime | DateTime | Last login time. |
Language | string | Language setting of the device. |
Channel | string | App release channel. |
Area | string | Country code of phone number. |
Phone | string | Phone number. |
string | Email. | |
SessionID | string | Session ID of the after login |
KidIndex | integer | Index of current selected kid. |
KidFace | string | Face icon of current selected kid. |
Children | SGChild | Kids of the member. |
property | type | desciption |
---|---|---|
Name | string | Name. |
Sex | string | Sex. |
Face | string | Face icon. |
Birthday | string | Birthday. |
pay
function.property | type | required | description |
---|---|---|---|
ProductID | string | Google Play or iTunes Connect product ID. | |
ProductName | string | Product name. | |
ProductDesc | string | Product description. | |
PaymentMethod | string |
Payment method. It's required when using Google IAP: managed subscription |
|
PaymentChannel | string |
Payment channel. Ex: AppStore GooglePay WeChat |
|
Price | float | Product price (USD). | |
ServerID | string | Server ID. | |
ServerName | string | Server Name. | |
RoleID | string | Role ID. | |
RoleName | string | Role name. | |
RoleLevel | integer | Role level. | |
NotifyUrl | string |
Notify URL. After payment, SG server notifies the URL to release the products。 |
|
OrderID | string | Order ID. | |
Receipt | string | IAP vendor receipt. |
pay
function.property | type | description |
---|---|---|
Code | integer | Response code. |
Message | string | Response message. |
Sign | string | Signature generated by SG server. |
ProductID | string | Google Play or iTunes Connect product ID. |
ProductName | string | Product name. |
ProductDesc | string | Product description. |
PaymentMethod | string |
Payment method. managed subscription |
PaymentChannel | string |
Payment channel. Ex: AppStore GooglePay WeChat |
Price | float | Product price. |
Currency | string | Currency. Default is USD. |
ServerID | string | Server ID. |
ServerName | string | Server Name. |
RoleID | string | Role ID. |
RoleName | string | Role name. |
RoleLevel | integer | Role level. |
OrderID | string | Order ID. |
Receipt | string | IAP vendor receipt. |