Answer the question
In order to leave comments, you need to log in
Pass gzip from PHP to Python?
You need to pass a compressed JSON string from the PHP server to the Python server.
I'm trying to do so
$json_out = "{"1":{"a1":3,"a2":0,"c":1,"d":1,"e":1},"2":{"a1":3,"a2":2,"c":3,"d":3,"e":1},"3":{"a1":3,"a2":2,"c":3,"d":1,"e":2}}";
$gz_data = gzcompress($json_out, 9, ZLIB_ENCODING_GZIP);
...
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(['json_out'=>$gz_data]));
gz_data = req.POST.get('json_out', 'undef')
json_in = gzip.decompress(gz_data)
gz_data_bytes = bytes(gz_data, 'utf-8')
json_in = gzip.decompress(gz_data_bytes )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question