$postParams = array(
'userId' => $userId, # 商家ID 必填
'status' => $status, # 服务状态 0:过期或者未购买 1:购买成功
'token' => $token,
);
//curl请求
$postJsonStr = json_encode($postParams);
$ch = curl_init("http://xxx.xxx.xxx/xxxx");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $postJsonStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($postJsonStr)
));
$dataJson = curl_exec($ch);
if (curl_errno($ch)) {
$result['msg'] = curl_error($ch);
return $result;
}else{
$data = json_decode($dataJson, true);
}
curl_close($ch);
CURL POST 数据
最新推荐文章于 2024-02-25 19:48:48 发布