Adding Backend to Corona using App42 Cloud APIs

In this blog post, we will take you through a quick start Corona game sample which uses leaderboard APIs to get you started with App42 backend APIs.

1 Adding Backend to Corona using App42 Cloud APIsFollowing are the steps to get started with it:

  1. Register with App42 platform.
  2. Create your App once you are on Quick Start page, and get your API Key and Secret Key
  3. If you are already registered, login to AppHQ console and get your API Key and Secret Key from App Manager –>Application Keys section.
  4. Create a new game in AppHQ console by clicking Add Game button in the Game panel (AppHQ Left Menu/Business Service Manager/Game Service/Game).
  5. Download the SDK & sample from our Git repo.
  6. Unzip the downloaded file on your system.
  7. Initialize App42 SDK by putting the APIKey & SecretKey in Constant.lua file (sample/App42-LeaderBoard-Sample/Constant.lua) and add your game name which you have created in the above steps and Constant file contains all the constants used in sample (e.g. username, email, password, game name etc.). Edit the variables as per your requirements.
  8. Save your project and run.

Design Details

Below are the API calls from App42 Corona SDK that has been used for social engagement and user management feature in this sample:

Initialize App42 Corona SDK

1
2
3
4
5
6
App42API:initialize("","")
local scoreBoardService = App42API:buildScoreBoardService()
local userService = App42API:buildUserService()
local gameName = "" -- Created in Step #4
local App42ScoreBoardCallBack = {}
local App42UserCallBack = {}

Saving user score on the cloud :-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local userName = "Nick" -- Name of the user for which you want to save score.
local gameName = "" -- Created in Step #4
local gameScore = 1000
scoreBoardService:saveUserScore(gameName,userName,gameScore, App42ScoreBoardCallBack);
 
function App42ScoreBoardCallBack:onSuccess(object)
print("Game name is "..object:getName())
print("userName is : "..game:getScoreList():getUserName())
print("score is : "..game:getScoreList():getValue())
print("scoreId is : "..game:getScoreList():getScoreId())
end
function App42ScoreBoardCallBack:onException(object)
print("Message is : "..object:getMessage())
print("App Error Code is : "..object:getAppErrorCode())
print("Http Error Code is : "..object:getHttpErrorCode())
print("Error Detail is : "..object:getDetails())
end

User Authentication :-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
local userName = "Nick"
local password = "**********"
userService:authenticate(userName,password,App42UserCallBack)
 
function App42UserCallBack:onSuccess(object)
print("User Name is : "..object:getUserName())
print("Session Id is : "..object:getSessionId())
end
function App42UserCallBack:onException(object)
print("Message is : "..object:getMessage())
print("App Error Code is : "..object:getAppErrorCode())
print("Http Error Code is : "..object:getHttpErrorCode())
print("Error Detail is : "..object:getDetails())
end

Visit our App42 documentation page to learn more. Please share your feedback with us at support@shephertz.com
.

twitter Adding Backend to Corona using App42 Cloud APIsfacebook Adding Backend to Corona using App42 Cloud APIsgoogle Adding Backend to Corona using App42 Cloud APIslinkedin Adding Backend to Corona using App42 Cloud APIspinterest Adding Backend to Corona using App42 Cloud APIsreddit Adding Backend to Corona using App42 Cloud APIsstumbleupon Adding Backend to Corona using App42 Cloud APIstumblr Adding Backend to Corona using App42 Cloud APIs

Leave a Reply

Your email address will not be published. Required fields are marked *


8 + = nine

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>