CURL POST 数据

xiaoxiao2021-02-28  100

$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);
转载请注明原文地址: https://www.6miu.com/read-60278.html

最新回复(0)