1. Android と php の間の相互作用
java
String body = "Lorem ipsum shizzle ma nizle"; URL url = new URL("http://some.url/file.php?id=" + uid); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setRequestProperty("Content-encoding", "deflate"); conn.setRequestProperty("Content-type", "application/octet-stream"); DeflaterOutputStream dos = new DeflaterOutputStream(conn.getOutputStream()); dos.write(body.getBytes()); dos.flush(); dos.close();
php
$content = http_get_request_body();$uncontent = gzuncompress($content);
2. iOS と php の間の相互作用
php は gzip 圧縮を受け取ります
gzdecode(base64_decode($json));//ios gzip uncompress
php は zlib 圧縮を受け取ります
gzuncompress(base64_decode($json));//ios zlib uncompress