php 访问java接口数据

    $header = [];
    $header[] = 'Accept:application/json';
    $header[] = 'Content-Type:application/json;charset=utf-8';
    $data = $_GPC['mobile'];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"url"); 
    curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
    curl_setopt($curl,CURLOPT_HEADER,1);  
    curl_setopt($ch, CURLOPT_POST, 1 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, '{"mobile":"'.$data.'"}');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $s = curl_exec($ch);
    $this->returnSuccess('success');
原文地址:https://www.cnblogs.com/hejianrong/p/9188668.html