Just want the full project? Download Source Code
Query and return all objects based on their distance from a specified GeoPoint.
BeginnerEstimated time to complete
| class User < ApplicationRecord | |
| has_many :posts | |
| has_many :comments | |
| # id :integer not null, primary key | |
| # name :string(50) default("") | |
| end |
Just want the full project? Download Source Code
Query and return all objects based on their distance from a specified GeoPoint.
BeginnerEstimated time to complete
| <?php | |
| namespace Stackmob; | |
| require_once("OAuth.php"); | |
| /** | |
| * Many thanks to jobiwankanobi@github and dancali@github for helping each other produce this StackMob OAuth 2.0 Signing PHP example. | |
| * | |
| * This code generates the value of the "Authorization" header to be passed on each request after a user signs in. | |
| * The accessToken is returned from the OAuth 2.0 login request. | |
| * |
| StackMob.init({ | |
| appName: '', | |
| clientSubdomain: '', | |
| publicKey: '', | |
| apiVersion: 0 | |
| }); |
| /* | |
| For chained functions, simply call the second, third, fourth functions in the "success" callbacks | |
| Callbacks: http://www.stackmob.com/devcenter/docs/Javascript-SDK-API#a-success | |
| These calls will execute in order 1 by 1, not simultaneously. | |
| */ | |
| var user = new StackMob.User({ username: 'chucknorris', password: 'myfists' }); | |
| user.login(false, { |
| StackMob.User = StackMob.User.extend({ | |
| forgotPassword : function(options) { | |
| options = options || {}; | |
| options['data'] = options['data'] || {}; | |
| //fixed the following line. It used to be options['data'][StackMob.loginField] | |
| options['data']['username'] = this.get(StackMob.loginField); | |
| (this.sync || Backbone.sync).call(this, "forgotPassword", this, options); | |
| } | |
| }); |
| /* | |
| These instructions are for JS SDK Version 0.2.1 and below on how to add | |
| custom user object with custom login/password fields. You have to let the | |
| JS SDK know what your primary key and password field is, so we'll do that here. | |
| */ | |
| //Let StackMob know what your username/pw fields are | |
| StackMob.init({ | |
| appName: ..., | |
| clientSubdomain: ..., |
| var users = new StackMob.Users(); | |
| users.count(null, { | |
| success: function(count) { | |
| //count is an integer representing number of all users | |
| } | |
| }); |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | |
| <script type="text/javascript" src="http://static.stackmob.com/js/json2-min.js"></script> | |
| <script type="text/javascript" src="http://static.stackmob.com/js/underscore-1.3.0-min.js"></script> | |
| <script type="text/javascript" src="http://static.stackmob.com/js/backbone-0.5.3-min.js"></script> | |
| <script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.1.1-min.js"></script> | |
| <script type="text/javascript"> |
| StackMobCommon.getStackMobInstance().forgotPassword("johndoe", new StackMobCallback() { | |
| @Override public void success(String response) { | |
| //forgotPassword succeeded | |
| } | |
| @Override public void failure(StackMobException e) { | |
| //forgotPassword failed | |
| } | |
| }); |