所以这就是问题所在。我正在尝试使用 PHP CURL 帖子调用我的 api,就像这样
<?php
$ch = curl_init();
$data = array('page' => $pageid);
$data = json_encode($data);
$fields = 'data=' . urlencode($data);
/*echo $fields; ## data=%7B%22page%22%3A%222%22%7D */
curl_setopt($ch, CURLOPT_URL, 'http://www.myurl.com/api/gallery');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result =curl_exec($ch);
$products=json_decode($result,true);
?>
在我使用zend框架的API中,我收到了这样的数据
<?php
$data = json_decode($this->_getParam('data',''), true);
$query = array();
$query['status'] = '1';
$query['pid'] = (isset($data['pid']))? $data['pid'] : '';
$query['search'] = (isset($data['search']))? $data['search'] : '';
$query['orderby'] = (isset($data['sort']))? $data['sort'] : 'latest';
$query['page'] = (isset($data['page']))? $data['page'] : '1';
$query['pagelimit'] = (isset($data['pagelimit']))? $data['pagelimit'] : '2';
?>
当我检查查询中的值时,它没有收到使用 CURL 传递的“页面”值。我做错了什么吗?
干杯