【问题标题】:Convert Parse Token Curl to Ajax将 Parse Token Curl 转换为 Ajax
【发布时间】:2014-08-18 19:12:02
【问题描述】:

我需要将其转换为 ajax。

curl -X POST \
                    -H "X-Parse-Application-Id: ****************" \
                    -H "X-Parse-REST-API-Key: ******************" \
                    -H "Content-Type: application/json" \
                    -d '{
                            "deviceType": "ios",
                            "deviceToken": "result" ,
                            "channels": [
                                ""
                                    ]
                        }' \
                        https://api.parse.com/1/installations

【问题讨论】:

    标签: ajax curl parse-platform token


    【解决方案1】:

    我发现解决方案是创建一个 ajax post 方法。因此,在本例中,您将执行以下 ajax 方法。

    var headers = {
       "X-Parse-Application-Id":"Your ID", 
       "X-Parse-REST-API-Key":"Your Rest API Key"
            };
        // Convert data object to JSON string:
    var userData = { "deviceType": "the device or the variable that says the device",
                     "deviceToken": "The Token itself or the variable with the token",
                     "channels": [""]
                   };
    var data = JSON.stringify(userData);
    
    
       $.ajax({
            headers: headers,
            type: 'POST',
            url: "https://api.parse.com/1/installations",
            contentType: "application/json",
            data: data,
            dataType:"json",
            success:function(data) {
    
            // We log the responce from the server just to check.
            alert("data:" + JSON.stringify(data) + " status: " + status); 
    
            },
            error:function(data) {
    
            // Show error message:
            alert("Your data didn't save!" + JSON.stringify(data));
            }
            });
    

    【讨论】:

      猜你喜欢
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 2017-01-26
      • 2015-10-06
      • 2018-02-15
      • 2016-10-10
      • 2021-02-14
      相关资源
      最近更新 更多