php封装amf数据,发送post
模拟客户端请求,AMF请求 封包,目前只有C#版本的,我没学过C#,想把它翻译成php版本的,但是非常蛋疼啊。想问下目前网上有类似功能的类库了吗?或者已经有相同功能的代码了吗?
<br> class AMF_Post_Data <br> { <br> public List<byte> message; <br> <br> /// <summary> <br> /// 初始化Message <br> /// </summary> <br> /// <param> <br> /// <param> <br> /// <param> <br> public AMF_Post_Data(AMFType at, int headers, int bodies) <br> { <br> //AMF版本 <br> if (at == AMFType.AMF0) <br> { <br> message = new List<byte>(new byte[] { 0x00, 0x00 }); <br> } <br> else if (at == AMFType.AMF3) <br> { <br> message = new List<byte>(new byte[] { 0x00, 0x03 }); <br> } <br> <br> //header数量 <br> message.Add(BitConverter.GetBytes(headers)[1]); <br> message.Add(BitConverter.GetBytes(headers)[0]); <br> //body数量 <br> message.Add(BitConverter.GetBytes(bodies)[1]); <br> message.Add(BitConverter.GetBytes(bodies)[0]); <br> } <br> <br> /// <summary> <br> /// 添加Target <br> /// </summary> <br> /// <param> <br> /// <param> <br> public void AddTargetAndResponse(string target, string Response) <br> { <br> //添加Target长度 <br> message.Add(BitConverter.GetBytes(target.Length)[1]); <br> message.Add(BitConverter.GetBytes(target.Length)[0]); <br> //添加Target内容 <br> message.AddRange(Encoding.Default.GetBytes(target)); <br> <br> //添加Response长度 <br> message.Add(BitConverter.GetBytes(Response.Length)[1]); <br> message.Add(BitConverter.GetBytes(Response.Length)[0]); <br> //添加Response内容 <br> message.AddRange(Encoding.Default.GetBytes(Response)); <br> } <br> <br> /// <summary> <br> /// 添加Body <br> /// </summary> <br> /// <param> <br> /// <param> <br> public void AddBody(AMF_Post_Data_Body apdb) <br> { <br> message.AddRange(apdb.getLength()); <br> message.AddRange(apdb.Content.ToArray()); <br> } <br> } <br> <br> class AMF_Post_Data_Body <div class="clear"> </div></byte></byte></byte>