php curl请求接口数据

代码如下:

$data = '{"method":"getOrderByUserIdNoAuth","parameter":{"userid":"' . $appUserId . '","appid":"5","offset":"' . $offset . '","limit":"5"}}';
$ch = curl_init ();
    
curl_setopt ( $ch, CURLOPT_URL, $uri );
// post
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
$return = curl_exec ( $ch );
// var_dump($return);die;
// 关闭curl
curl_close ( $ch );
$json = json_decode($return);
// echo '
';
// var_dump($json->{'result'});die;
$de_json =$json->{'result'};
$count_json = count($json->{'result'});

你可能感兴趣的:(php curl请求接口数据)