Alamofire发帖请求FAILURE错误

时间:2017-05-29 06:00:42

标签: php swift heroku alamofire stripe-payments

我目前正在使用Stripe,尝试使用Alamofire和Heroku向我的后端发送Stripe令牌。我的代码如下:

func postStripeToken(_ token: STPToken) {

    let URL = "https://limitless-fjord-73001.herokuapp.com/charge.php"
    let params = ["stripeToken": token.tokenId,
                  "amount": Int(self.amountTextField.text!)!,
                  "currency": "usd"] as [String : Any]

    Alamofire.request(URL, method: .post, parameters: params)
        .responseJSON { response in
              print(response.request as Any) // original URL request
              print(response.response as Any) // URL response
              print(response.data as Any) // server data
              print(response.result as Any) // result of response serialization

            if let JSON = response.result.value {
                print("JSON: \(JSON)")
            }

    }
}

我遇到的问题是我的response.result打印为FAILURE(参见上面的第13行)。其他一切似乎都打印得很好,包括令牌和行response.request,response.response和response.data:

    Optional(https://limitless-fjord-73001.herokuapp.com/charge.php)
Optional(<NSHTTPURLResponse: 0x600000425400> { URL: https://limitless-fjord-73001.herokuapp.com/charge.php } { status code: 500, headers {
    Connection = "keep-alive";
    "Content-Length" = 0;
    "Content-Type" = "text/html; charset=UTF-8";
    Date = "Mon, 29 May 2017 05:58:35 GMT";
    Server = Apache;
    Via = "1.1 vegur";
} })
Optional(0 bytes)
FAILURE

关于我为什么会失败的任何想法?谢谢!

1 个答案:

答案 0 :(得分:0)

很难说出你向我们展示的那个小问题是什么:)

然而,这一行:

FIND_IN_SET(concat(formid, '-', formversionid), '$formsidlist') ORDER BY id";

更具体的这一部分:

Optional(<NSHTTPURLResponse: 0x600000425400> { URL: https://limitless-fjord-73001.herokuapp.com/charge.php } { status code: 500, headers {

似乎表示您从后端收到错误代码500,这意味着存在某种服务器端错误。

那么,您的服务器上是否有一个日志文件,您可以查看它并查看它是否告诉您某些内容?

希望能为你提供一些工作。