Php 如何在JSON中解码分页?

Php 如何在JSON中解码分页?,php,json,api,Php,Json,Api,我正在尝试使用chinavasion.com的API为我的网站填充产品。我已经成功地获取了某个类别下的产品列表,但是JSON的响应只给出了10个产品和一个分页,我真的不知道如何使用它,我猜它可能是限制echo’d产品列表的一个 以下是示例JSON响应: { "products": [ { "product_id": 19433, "model_code": "CVABR-C405", "short_product_name": "13.3 Inch Roof Mounte

我正在尝试使用chinavasion.com的API为我的网站填充产品。我已经成功地获取了某个类别下的产品列表,但是JSON的响应只给出了10个产品和一个分页,我真的不知道如何使用它,我猜它可能是限制echo’d产品列表的一个

以下是示例JSON响应:

{
 "products": [
  {
   "product_id": 19433,
   "model_code": "CVABR-C405",
   "short_product_name": "13.3 Inch Roof Mounted Car Monitor  ",
   "product_url": "http://www.chinavasion.com/china/wholesale/Car_Video/Roof_Monitors/13.3-Inch-Roof-Mounted-Car-Monitor/",
   "category_name": "Car Video",
   "category_url": "http://www.chinavasion.com/china/wholesale/Car_Video/",
   "subcategory_name": "Roof Monitors",
   "status": "In Stock"
  },
   .... and 9 more.

 "pagination": {
  "start": 0,
  "count": 10,
  "total": 53
 }
}
这是我的PHP到目前为止,我只想回显所有项目的所有简短产品名称,我只得到10个项目,但总共有53个项目。(可以在示例JSON响应分页总计上看到)



那么,目前是否有办法获取其余43种产品?我不确定这是否可能,因为我对编程非常陌生,以前也没有做过JSON,希望你们能帮助我。

分页数组的存在表明还有更多的项目。您只需传递一个
start
变量即可获得下一个10。可以将其视为SQL中的一个偏移量。

分页数组用于指示有更多项。您只需传递一个
start
变量即可获得下一个10。将其视为SQL中的偏移量。

接下来的10项:

$API_KEY = '4rxVx5-bxo7ldVQ5GcPSmX8XeqcSZoTnJnxF7xhRr8g.';
$url = "https://secure.chinavasion.com/api/getProductList.php";
$data = array(
'key' => $API_KEY,
'categories' => array('Car Video'),
'pagination' => array('start' => 10)
);

$content = json_encode($data);
更改“pagination”=>“start”参数可以设置起始项索引

编辑: 必须在“分页”数组中插入“start”参数。 另一种方法是将“count”参数设置为一个大数字。这样,您将在一次通话中收到所有项目

$API_KEY = '4rxVx5-bxo7ldVQ5GcPSmX8XeqcSZoTnJnxF7xhRr8g.';
$url = "https://secure.chinavasion.com/api/getProductList.php";
$data = array(
'key' => $API_KEY,
'categories' => array('Car Video'),
'pagination' => array('count' => 999)
);
下10项:

$API_KEY = '4rxVx5-bxo7ldVQ5GcPSmX8XeqcSZoTnJnxF7xhRr8g.';
$url = "https://secure.chinavasion.com/api/getProductList.php";
$data = array(
'key' => $API_KEY,
'categories' => array('Car Video'),
'pagination' => array('start' => 10)
);

$content = json_encode($data);
更改“pagination”=>“start”参数可以设置起始项索引

编辑: 必须在“分页”数组中插入“start”参数。 另一种方法是将“count”参数设置为一个大数字。这样,您将在一次通话中收到所有项目

$API_KEY = '4rxVx5-bxo7ldVQ5GcPSmX8XeqcSZoTnJnxF7xhRr8g.';
$url = "https://secure.chinavasion.com/api/getProductList.php";
$data = array(
'key' => $API_KEY,
'categories' => array('Car Video'),
'pagination' => array('count' => 999)
);

尝试将
'start'=>10
添加到您的
$data
散列中,看看会发生什么。@RobbyCornelissen lol您在评论中击败了我。是的,他只需要传递一个偏移量就可以得到下一个10。试着将
'start'=>10
添加到你的
$data
散列中,看看会发生什么。@RobbyCornelissen lol你在评论中击败了我。是的,他只需要通过一个偏移量就可以得到下一个10