Skip to content

Instantly share code, notes, and snippets.

@tyfkda
Last active November 20, 2020 01:42
Show Gist options
  • Save tyfkda/ec5c55f775d5203b92e4 to your computer and use it in GitHub Desktop.
Save tyfkda/ec5c55f775d5203b92e4 to your computer and use it in GitHub Desktop.
C#からParse.comのCloudFunctionを呼び出して結果を受け取る ref: http://qiita.com/tyfkda/items/be2858031203921bb505
Parse.Cloud.define('getFoobars', function(request, response) {
var query = new Parse.Query('Foobars');
query.containedIn('foobarId', request.params.foobarIds);
query.find({
success: function(results) {
response.success(results);
},
error: function() {
response.error('find failed');
}
});
});
using Parse;
...
public void RequestFoobars(List<string> foobarIds) {
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("foobarIds", foobarIds);
ParseCloud.CallFunctionAsync<List<object>>("getFoobars", data).ContinueWith(t => {
if (t.IsFaulted || t.IsCanceled || !t.IsCompleted || t.Result == null) {
Debug.Log(t.Exception.GetBaseException().Message);
return;
}
foreach (object obj in t.Result) {
if (obj is ParseObject) {
ParseObject pobj = obj as ParseObject;
string foobarId = pobj.Get<string>("foobarId");
DateTime? updatedAt = pobj.UpdatedAt;
...
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment