PHP curl传 json字符串

     $ch = curl_init();

        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );

         curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );

        curl_setopt($ch, CURLOPT_HTTPHEADER, array(

            'Content-Type: application/json; charset=utf-8',

            'Content-Length: '.strlen($data))

     );

服务端获取:

   $GLOBALS['HTTP_RAW_POST_DATA']

你可能感兴趣的:(json)