Appdata
Endpoint for Social API
Note: Social API includes Appdata API, Blacklist API, People API, Profanity API, Leaderboard API, Remote Notification API.
Mobage Simplified Chinese Platform
Production Social | http://sp.mobage-platform.cn/social/api/restful/v2 |
Sandbox Social | http://sp.sb.mobage-platform.cn/social/api/restful/v2 |
Environment | URL |
---|
Mobage Traditional Chinese Platform
Environment | URL |
---|---|
Production Social | http://sp.mobage-platform.tw/social/api/restful/v2 |
Sandbox Social | http://sp.sb.mobage-platform.tw/social/api/restful/v2 |
REST API Name | HTTP Method | REST URI Fragment | Description |
---|---|---|---|
Create Appdata | POST | /appdata/{userId}/{groupId}/{appId} | Create application data |
Get Appdata | GET | /appdata/{userId}/{groupId}/{appId} | Acquires informaton specific to an app, such as a user's current score. |
Update Appdata | PUT | /appdata/{userId}/{groupId}/{appId} | Update the contents of one appdata |
Delete Appdata | DELETE | /appdata/{userId}/{groupId}/{appId} | Delete data of certain app |
Data Type Definition
An isolated AppData
Simple hash of key/value pairs.
Simple hash of key/value pairs are stored by users in entry field.
Create Appdata
Description
Create Appdata for your application.
URI Fragment
/appdata/{userId}/{groupId}/{appId}
Supported Formats
JSON
HTTP Method
POST
Request Parameters
Name | Type | Required | Parameter | Description |
---|---|---|---|---|
userId | UserId | * | URI Template Parameters | Only @me is specifiable |
groupId | GroupId | * | URI Template Parameters | Only @self is specifiable |
appId | AppId | * | URI Template Parameters | Only @app is specifiable |
fields | Array | * | Query String | The keys of appdata are specifiable |
format | String | Query String | Only json is specifiable |
Request Body
An isolated AppData, which is defined by developers.
Request Headers
Any request to the Mobage REST APIs must include the Authorization header. For more details, see How to add the Authorization Header.
Response Status Code
HTTP Status Code | HTTP Status Message | Meaning |
---|---|---|
201 | Created | Data successfully created or updated |
400 | Bad Request | Corrupt request data on the client side |
401 | Unauthorized | Authorization error |
403 | Forbidden | The resource exists, but access is not possible due to a reason other than an authorization error. |
404 | Not Found | The resource doesn’t exist |
500 | Internal Server Error | An error on the API server side |
503 | Service Unavailable | The API cannot be used temporarily |
Response Body
N/A
Notes
1.Keys can be up to 32 bytes in size. Values can be up to 1024 bytes in size.
2.Maximum number of key/value pairs are 30 entries per user in an application.
Example.
Get Appdata
Description
Acquires informaton specific to an app, such as a user's current score.
URI Fragment
/appdata/{userId}/{groupId}/{appId}
Supported Formats
JSON
HTTP Method
GET
Request Parameters
Name | Type | Required | Parameter | Description |
---|---|---|---|---|
userId | UserId | * | URI Template Parameters | Only @me is specifiable |
groupId | GroupId | * | URI Template Parameters | Only @self is specifiable |
appId | AppId | * | URI Template Parameters | Only @app is specifiable |
fields | Array | Query String | The keys of appdata are specifiable, which are defined in "Create Appdata" | |
format | String | Query String | Only json is specifiable |
Request Body
None
Request Headers
Any request to the Mobage REST APIs must include the Authorization header. For more details, see How to add the Authorization Header.
Response Body
Response Status Code
HTTP Status Code | HTTP Status Message | Meaning |
---|---|---|
200 | OK | Data successfully acquired |
400 | Bad Request | Corrupt request data on the client side |
401 | Unauthorized | Authorization error |
403 | Forbidden | The resource exists, but access is not possible due to a reason other than an authorization error. |
404 | Not Found | The resource doesn’t exist |
500 | Internal Server Error | An error on the API server side |
503 | Service Unavailable | The API cannot be used temporarily |
Notes
Leaving the fields
parameter blank will return entire entries. If the target keys are known beforehand, the fields
parameter must be specified.
Example .
Update Appdata
Description
Update the contents of one appdata
URI Fragment
/appdata/{userId}/{groupId}/{appId}
Supported Formats
JSON
HTTP Method
PUT
Request Parameters
Name | Type | Required | Parameter | Description |
---|---|---|---|---|
userId | UserId | * | URI Template Parameters | Only @me is specifiable |
groupId | GroupId | * | URI Template Parameters | Only @self is specifiable |
appId | AppId | * | URI Template Parameters | Only @app is specifiable |
fields | Array | * | Query String | The keys of appdata are specifiable |
format | String | Query String | Only json is specifiable |
Request Body
An isolated AppData. Simple hash of key/value pairs.
{
"key1"
:
"value1"
,
"key2"
:
"value2"
}
Request Headers
Any request to the Mobage REST APIs must include the Authorization header. For more details, see How to add the Authorization Header.
Response Status Code
HTTP Status Code | HTTP Status Message | Meaning |
---|---|---|
201 | Created | Data successfully created or updated |
400 | Bad Request | Corrupt request data on the client side |
401 | Unauthorized | Authorization error |
403 | Forbidden | The resource exists, but access is not possible due to a reason other than an authorization error. |
404 | Not Found | The resource doesn’t exist |
500 | Internal Server Error | An error on the API server side |
503 | Service Unavailable | The API cannot be used temporarily |
Response Body
N/A
Notes
1.Keys can be up to 32 bytes in size. Values can be up to 1024 bytes in size.
2.Maximum number of key/value pairs are 30 entries per user in an application.
Example.
Delete Appdata
Description
Delete appdata of certain app
URI Fragment
/appdata/{userId}/{groupId}/{appId}
Supported Formats
JSON
HTTP Method
DELETE
Request Parameters
Name | Type | Required | Parameter | Description |
---|---|---|---|---|
userId | UserId | * | URI Template Parameters | Only @me is specifiable |
groupId | GroupId | * | URI Template Parameters | Only @self is specifiable |
appId | AppId | * | URI Template Parameters | Only @app is specifiable |
fields | Array | * | Query String | The keys of appdata are specifiable, which are defined in "Create Appdata" |
format | String | Query String | Only json is specifiable |
Request Body
None
Request Headers
Any request to the Mobage REST APIs must include the Authorization header. For more details, see How to add the Authorization Header.
Response Body
None
Response Status Code
HTTP Status Code | HTTP Status Message | Meaning |
---|---|---|
202 | Accepted | Data successfully deleted |
400 | Bad Request | Corrupt request data on the client side |
401 | Unauthorized | Authorization error |
403 | Forbidden | The resource exists, but access is not possible due to a reason other than an authorization error. |
404 | Not Found | The resource doesn’t exist |
500 | Internal Server Error | An error on the API server side |
503 | Service Unavailable | The API cannot be used temporarily |
Example
How to Add the Authorization Header
Step 1. Create the base string
1. build a string for OAuth parameters: firstly sort the following parameters alphabetically and URL encode the names and values, then join name and value with "=", finally join name/value pairs with "&"
Parameter | Description | Value |
---|---|---|
oauth_consumer_key | The Consumer Key for the application | Issued when resist the application |
oauth_nonce | Unique value for each request | Generated on the game server |
oauth_signature_method | Hash method | Only HMAC-SHA1 is specifiable |
oauth_timestamp | UNIX timestamp | Generated on the game server |
oauth_token | The token code | oauth_token is obtained from the token credential. |
oauth_version | OAuth version | Only 1.0 |
2. URL encode the following three parameters.
Parameter | Description |
---|---|
Request Method | HTTP Method to the API Server |
API URL | URL to the API Server (exclude query parameters) |
OAuth Parameters | A string Built in previous step |
3. join the encoded parameters with "&".
Step 2. Generate the oauth_signature
1. Build a secret by joining the Consumer Secret and the Token Secret (obtained from the token credential) with "&"
.
2. Pass the base string and secret to the HMAC-SHA1 hashing algorithm.
3. the output of HMAC-SHA1 hashing algorithm is a binary string. Use base64 encode to produce the signature string.
A tool is provided to verify whether your signature is correct. Refer to Oauth Signature Tool.
Step 3. Build the Authorization Header
Follow the steps to build the “Authorization” header:
1. URL encode the parameter names and values in the table below
2. Double quote the value, join name and value with "=", join name/value pairs with ","
3. Add realm parameter as an option
4. Add "OAuth " (including the space at the end) to the beginning of the header.
Parameter | Value |
---|---|
oauth_consumer_key | Issued when resist the application |
oauth_nonce | Generated on the game server |
oauth_signature | Generated on the game server, Refer to Step 2. Generate the oauth_signature |
oauth_signature_method | only "HMAC-SHA1" is specifiable |
oauth_timestamp | Generated on the game server |
oauth_token | oauth_token is obtained from the token credential. |
oauth_version | Only 1.0 |
Authorization Header Example