美文网首页
php curl请求接口数据

php curl请求接口数据

作者: 积_渐 | 来源:发表于2018-06-14 17:18 被阅读139次

    代码如下:

    $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 '<pre>';
    // var_dump($json->{'result'});die;
    $de_json =$json->{'result'};
    $count_json = count($json->{'result'});
    

    相关文章

      网友评论

          本文标题:php curl请求接口数据

          本文链接:https://www.haomeiwen.com/subject/wsnyeftx.html