Step1: Load JSSDK
<script type="text/javascript" src="https://h-cdn.pengpengla.com/up/opengamejs/1.4.0/assets/seed.js"></script> |
- Download: seed.js
- Demo: http://sg-oauth-demo.pengpengla.com:8000/index.html
- Demo zip: http://sg-oauth-demo.pengpengla.com:8000/openplatform_demo.zip
Step2: Initialize JSSDK
Call openSdk.init before any other API.
openSdk.init(Object object)
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
| env | No | pro | stage = test, pro = production |
| client_id | Yes | Application ID | |
| game_id | Yes | Game ID | |
| mode | Yes | diamond / gold / ad |
Example
openSdk.init({ |
Step3: APIs
openSdk.oauth(Object object)
Re-authorize when credentials expire. After success, code is appended to the game URL.
Parameters
| Parameter | Required | Description |
|---|---|---|
| redirect_url | Yes | Callback URL (usually current page) |
Example
openSdk.oauth({ |
openSdk.recharge(Object object)
Open recharge UI.
Parameters
| Parameter | Required | Description |
|---|---|---|
| upliveCode | Yes | User Funpepper code |
| countryCode | Yes | Country for payment channel (e.g. tw:mycard, id:codapay, in:paytm, other:PayPal) |
| lang | Yes | Language code from URL _lang |
| success | No | Success callback |
| fail | No | Failure callback |
| cancel | No | Cancel callback |
Example
openSdk.recharge({ |
openSdk.ping(Object object)
Required — report PV/UV when user enters the game.Parameters
| Parameter | Required | Description |
| – | – | – |
| open_id | Yes | User open_id in your game |
| success | No | Success callback |
Example
openSdk.ping({ |
### openSdk.quitGame()
Exit game and return to lobby.
openSdk.quitGame(); |
### openSdk.receiveGold(object object)
Required in gold mode
Claim daily free gold (once per user per day). Not used in U Diamond mode.
Parameters
| Parameter | Required | Description |
|---|---|---|
| open_id | Yes | User open_id |
| getGoldSuccess | Yes | Callback after claim; refresh balance here |
Example
openSdk.receiveGold({ |
openSdk.rechargeGold()
Open gold recharge page (gold mode only).
openSdk.rechargeGold(); |
openSdk.ads.showLandingVideo(object object)
Landing page with intro and video ad.
Parameters
| Parameter | Required | Description |
|---|---|---|
| start | Yes | Callback when user taps “Start game” |
Example
openSdk.ads.showLandingVideo({ |
openSdk.ads.showRewardVideo(object object)
Rewarded video ad.
Parameters
| Parameter | Required | Description |
|---|---|---|
| open_id | Yes | User open_id |
| success | Yes | User completed video; grant reward on server |
| close | Yes | true if finished and closed; false if closed early |
| error | Yes | Ad load failed |
Example
openSdk.ads.showRewardVideo({ |
Step4: Upgrade v1.2.2 → v1.2.3
Gold mode
- Removed:
openSdk.receiver(Number) - Added:
openSdk.rechargeGold() - Renamed:
openSdk.getGold→openSdk.receiveGold(call on each game entry)
U Diamond mode
No changes; v1.2.2 still works for U Diamond games.
Step5: Upgrade v1.2 → v1.3.0
inviteFriendsPlayGame
Parameters
| Parameter | Required | Description |
|---|---|---|
| direction | Yes | 0 bottom, 1 bottom-left mirror, 2 bottom-right mirror |
| gameId | Yes | Game ID (1h share limit per game per recipient) |
| gameIcon | Yes | Icon URL |
| inviteGameUrl | Yes | Share link |
| titleList | Yes | Invite titles by locale |
| contentList | Yes | Descriptions |
| highlightContentList | Yes | Highlight text |
| jsCallback | Yes | Protocol callback |
Example
openSdk.inviteFriendsPlayGame({ |