Parse.com从回调网址获取数据 [英] Parse.com getting data from callback URL

查看:158
本文介绍了Parse.com从回调网址获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用API​​和API,该应用程序的开发人员控制台会要求开发人员提交回调网址。每当应用程序的用户执行某些操作时,它都会向回调URL提交GET请求,并且可以从该请求中检索数据。我正在使用的当前网址是 https:// appId:javascript- key=myJavascriptKey@api.parse.com/1/functions/receiveInfo 。如何从GET请求处理数据,a.k.a GET参数?我在Parse.com上找到了一个答案,说如何从POST请求中检索数据,但它所说的是data = request.body 。我是否也对GET请求做同样的事情?如果是这样,我该怎么做? request.body 一个json值?

  Parse.Cloud.define (receiveInfo,function(request,response){

var params = request.body; //是否有权获取它们发送的GET参数?如果是这样,下一步该做什么?

});


解决方案

文档的解决方案如下: https://parse.com/docs/cloud_code_guide#functions



对于GET请求,您必须使用 request.params 对象,其中包含GET的所有请求参数。 POSTS在请求体中发送,GET在请求参数中。



它看起来像你试图获得参数,你可以使用类似的东西:


$ b $ pre $ Parse.Cloud.define(myMethod,function(request,response){
if(request.params.myparam == moo){
response.success(Cow!);
}
else {
response.error(未知类型的动物);
}
});


I'm currently trying to use an API and for the API, the developer console of that app asks the developer to submit a callback URL. Whenever the user of the app does something, it submits a GET request to the callback URL and I can retrieve data from that request. The current url I am using is https://appId:javascript-key=myJavascriptKey@api.parse.com/1/functions/receiveInfo. How can I handle the data, a.k.a the GET parameters, from the GET request? I found an answer on Parse.com that says how to retrieve data from a POST request, but all it says is that data = request.body. Do I do the same for GET requests and if so what do I do after that? Is request.body a json value?

Parse.Cloud.define("receiveInfo", function(request,response){

        var params = request.body;//is this right to get the GET parameters they send? if so what do I do next?

    });

解决方案

The documentation has your solution at: https://parse.com/docs/cloud_code_guide#functions

For GET requests you have to use the request.params object which has all your request parameters for a GET are there. POSTS are sent in the request body, GET in the request parameters.

It looks like you are trying to get the params you can use something similar to:

Parse.Cloud.define("myMethod", function(request, response) {
  if(request.params.myparam == "moo") {
    response.success("Cow!");
  }
  else {
    response.error("Unknown type of animal");
  }
});

这篇关于Parse.com从回调网址获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆