$value) { $buffer .= pack("S", $key); $buffer .= pack("S", strlen($value)) . $value; } return strtoupper(hash_hmac('sha1', $buffer, $rawAppCertificate)); } function packString($value) { return pack("S", strlen($value)) . $value; } function packContent($serviceType, $signature, $appID, $ts, $salt, $expiredTs, $extra) { $buffer = pack("S", $serviceType); $buffer .= packString($signature); $buffer .= packString($appID); $buffer .= pack("I", $ts); $buffer .= pack("I", $salt); $buffer .= pack("I", $expiredTs); $buffer .= pack("S", count($extra)); foreach ($extra as $key => $value) { $buffer .= pack("S", $key); $buffer .= packString($value); } return $buffer; } ?>