0

任何关于我需要做什么来返回以下信息的指导或示例都会很棒。我正在使用 js、jquery 和 HTML

  1. 我需要添加这个: Content-Type header is application/json
  2. 当请求到来时,我需要用下面的 Json 回复

https://docs.snipcart.com/configuration/json-crawler#validating-the-request

当 Snipcart 向 URL 发出请求时,如果您的响应 Content-Type 标头是 application/json,我们将使用我们的 JSON 验证器而不是 HTML 验证器。

您必须向我们返回具有以下属性的 JSON。

{
  "id": "20",
  "price": 50.00,
  "url": "https://snipcart.com/products/1.json"
}
4

1 回答 1

0

我最终在 PHP 中执行此操作并使用 URL 获取值。

<?php
    header('Content-Type: application/json');

    $myID = $_REQUEST['scene'];
    $myPrice = $_REQUEST['price'];

    $data = [
      "id" => $myID,
      "price" => $myPrice,
      "url" => "https://yoursite.com/shop/test/snipcart.php" 
    ];
    echo json_encode( $data );
?>
于 2018-01-25T00:13:48.980 回答