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.mob1.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 {
}
}];
StackMobCommon.getStackMobInstance().get("hello_world", new StackMobCallback() {
@Override public void success(String responseBody) {
//responseBody is "{ \"msg\": \"Hello, world!\" }"
}
@Override public void failure(StackMobException e) {
}
});
<script type="text/javascript">
StackMob.customcode('hello_world', {}, {
success: function(jsonResult) {
//jsonResult is the JSON object: { "msg": "Hello, world!" }
},
error: function(failure) {
//doh!
}
});
</script>
Building:
- cd java
- mvn clean package
- JAR is located in java/target
- Upload JAR to StackMob
Building:
- cd scala-maven
- mvn clean package
- JAR is located in scala/target
- Upload JAR to StackMob
Building:
- cd scala-sbt
- sbt clean package
- JAR is located in scala/target/scala-2.9.1
- Upload JAR to StackMob
Building:
- cd clojure
- mvn clean package
- JAR is located in clojure/target
- Upload JAR to StackMob