/**
* post 发送JSON 格式数据
* @param $url string URL
* @param $data_string string 请求的具体内容
* @return array
* code 状态码
* result 返回结果
*/
public static function postJsonData($url, $data = NULL)
{
//https://mall.xiangtuan.xyz/api/commodity/product/list/wOfU8PT0rR/762228872210333985
//{"pageNum":1,"pageSize":10,"sortedType":1,"sortedModel":1}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-Type: application/json; charset=utf-8','Content-Length:' . strlen($data)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($curl);
$errorno = curl_errno($curl);
if ($errorno) {
return array('errorno' => false, 'errmsg' => $errorno);
}
curl_close($curl);
return json_decode($res, true);
}
$getCardPicUrl = "https://mall.xiangtuan.xyz/api/commodity/product/list/".$linkDatas['shopId']."/".$linkDatas['activityNo'];
$postData = [
"pageNum" => 1,
"pageSize" =>10,
"sortedType" =>1,
"sortedModel" => 1
];
$CardDatas = Utils::postJsonData($getCardPicUrl,json_encode($postData));