Skip to content

fashionwalk/stackmob-customcode-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.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 {
    }
}];
**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

Scala (Maven)

Building:

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

Scala (sbt)

Building:

  1. cd scala-sbt
  2. sbt clean package
  3. JAR is located in scala/target/scala-2.9.1
  4. Upload JAR to StackMob

Clojure (Maven)

Building:

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

About

StackMob Custom Code Example Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published