Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
StackMob Custom Code Example Project
Java
Branch: master
Pull request Compare This branch is 46 commits ahead of fashionwalk:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/main
.gitignore
LICENSE.txt
README.md
buh
pom.xml

README.md

StackMob Custom Code Example Projects

This example project is a simple Hello World. This adds a server-side method called "hello_world" which can be called from your client iOS, Android, Java Client or JS SDKs:

http://api.stackmob.com/hello_world

Custom code allows you to even define the returned JSON. In this case, our simple Hello World example will return:

{ "msg": "Hello, world!" }

You can call your server-side custom code from your SDK. The request will be sent from the client, StackMob will route the call to the appropriate code and execute the code you've written, then StackMob will return the JSON you've defined.

iOS SDK

[[StackMob stackmob] get:@"hello_world" withCallback:^(BOOL success, id result) {
    if (success) {
        // result is the JSON as an NSDictionary of "msg" vs. "Hello, world!"
    } else {
    }
}];

Android SDK

StackMobCommon.getStackMobInstance().get("hello_world", new StackMobCallback() {
    @Override public void success(String responseBody) {
        //responseBody is "{ \"msg\": \"Hello, world!\" }"
    }
    @Override public void failure(StackMobException e) {
    }
});

JS SDK

<script type="text/javascript">
  StackMob.customcode('hello_world', {}, {
     success: function(jsonResult) {
       //jsonResult is the JSON object: { "msg": "Hello, world!" }
     },

     error: function(failure) {
       //doh!
     }
  });
</script>

Java (Maven)

Building:

  1. cd java
  2. mvn clean package
  3. JAR is located in java/target
  4. Upload JAR to StackMob

or you know... github integration thingie

Something went wrong with that request. Please try again.