如何使用的Azure移动服务API功能 [英] How to use the Azure Mobile Service API feature
问题描述
在 API 的功能已经被添加到WAMS在那里我可以定义自定义脚本。这似乎去precate创建脚本表的previous做法。但是,我找不到任何关于我如何使用它的任何说明。
An API feature has been added to WAMS where I can define custom scripts. This seems to deprecate the previous practice of creating a script table. However, I couldn't find any description about how I can use it.
哪些客户端使此功能访问?它可以从iOS或使用的Javascript?
Which clients make this feature accessible? Can it be used from iOS or Javascript?
推荐答案
和一对夫妇关于这一主题的更多帖子:<一href=\"http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile-services.aspx\">http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile-services.aspx (服务器端)和<一href=\"http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/19/custom-api-in-azure-mobile-services-client-sdks.aspx\">http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/19/custom-api-in-azure-mobile-services-client-sdks.aspx (客户端)。
And a couple more posts on this topic: http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile-services.aspx (server side) and http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/19/custom-api-in-azure-mobile-services-client-sdks.aspx (client side).
此外,由于你的ios标记你的问题,这里的code你会使用调用使用 MSCLIENT
类的一个实例的API:
Also, since you tagged your question with ios, here's the code you'd use to call the API using an instance of the MSClient
class:
如果您的API只处理(接收/返回)JSON数据:
If your API only deals with (receives / returns) JSON data:
MSClient *client = [MSClient clientWithApplicationURLString:@"https://your-service.azure-mobile.net"
applicationKey:@"your-application-key"];
[client invokeApi:@"calculator/add"
body:nil
HTTPMethod:@"GET"
parameters:@{@"x":@7, @"y":@8} // sent as query-string parameters
headers:nil
completion:^(id result, NSURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];
或用请求主体(POST):
Or with a request body (POST):
[client invokeApi:@"calculator/sub"
body:@{@"x":@7, @"y":@8} // serialized as JSON in the request body
HTTPMethod:@"POST"
parameters:nil
headers:nil
completion:^(id result, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];
如果与非JSON数据你的API的交易,你可以用其他的选择这需要/返回的NSData code>对象:
If your API deals with non-JSON data, you can use the other selector which takes / returns a NSData
object:
NSData *image = [self loadImageFromSomePlace];
[client invokeApi:@"processImage"
data:image
HTTPMethod:@"POST"
parameters:nil
headers:nil
completion:^(NSData *result, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];
这篇关于如何使用的Azure移动服务API功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!