Ejemplo n.º 1
0
        public static void SendFriendAudio(long thisQQ, long sendQQ, byte[] AudioBytes)
        {
            using (var audioStream = new MemoryStream(AudioBytes))
            {
                AudioBytes = audioStream.ToArray();
            }
            API.FileHash = API.MD5Hash(AudioBytes);
            SendAudioMsgStruct AudioInfo = new SendAudioMsgStruct
            {
                AudioType = 500,
                Field2    = 0,
                AudioInfo = new AudioInfos
                {
                    thisQQ    = thisQQ,
                    SendQQ    = sendQQ,
                    StartFlag = 2,
                    AudioSize = AudioBytes.Length,
                    AudioName = API.HashMD5(AudioBytes) + ".amr",
                    AudioHash = API.FileHash
                },
                Field101       = 17,
                Field102       = 104,
                AudioOtherInfo = new AudioOtherInfos
                {
                    Field1     = 3,
                    Field2     = 0,
                    Field90300 = 1,
                    Field90500 = 3,
                    Field90600 = 2,
                    Field90800 = 5
                }
            };

            using (var ms = new MemoryStream())
            {
                Serializer.Serialize(ms, AudioInfo);
                var bytes = API.PackCmdHeader("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500", ms.ToArray());
                API.TClient.SendData(API.PackAllHeader(bytes));
            }
        }
Ejemplo n.º 2
0
        public static string GetFriendAudioUrl(byte[] BytesIn, byte[] token)
        {
            BytesIn = BytesIn.Skip(4).ToArray();

            SendAudioMsgStruct GetAudioInfo = new SendAudioMsgStruct
            {
                AudioType    = 1200,
                Field2       = 0,
                GetAudioInfo = new GetAudioInfos
                {
                    thisQQ = API.QQ.LongQQ,
                    token  = token
                },
                Field101       = 17,
                Field102       = 104,
                AudioOtherInfo = new AudioOtherInfos
                {
                    Field1     = 3,
                    Field2     = 104,
                    Field90300 = 0,
                    Field90700 = 0,
                    Field91100 = 1
                }
            };

            using (var mStream = new MemoryStream())
            {
                Serializer.Serialize(mStream, GetAudioInfo);
                Debug.Print("构造语音:" + "\r\n" + BitConverter.ToString(mStream.ToArray()).Replace("-", " "));
                var bytes = API.PackCmdHeader("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_DOWNLOAD-1200", mStream.ToArray());
                API.TClient.SendData(API.PackAllHeader(bytes));
            }

            ///上传语音
            //var url = "http://" + sAddr + "/?ver=2&ukey=" + BitConverter.ToString(uKey).Replace("-", "") + "&filekey=" + BitConverter.ToString(filekey).Replace("-", "") + "&filesize=" + fileSize.ToString() + "&bmd5=" + BitConverter.ToString(filekey).Replace("-", "") + "&range=0&Audio_codec=1&mType=pttCu";
            //Dictionary<string, object> Headerdics = new Dictionary<string, object>()
            //{
            //	{"User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0; SM-G9009D Build/LRX21T"},
            //	{"Content-Type", "application/x-www-form-urlencoded"},
            //	{"Host", sAddr}
            //};
            //var res = HttpHelper.HttpClientPostAsync2(url, Headerdics, fileByte, "application/x-www-form-urlencoded", mycookiecontainer, RedirectUrl).Result;

            using (var ms = new MemoryStream(BytesIn))
            {
                var result = Serializer.Deserialize <AudioHashStruct>(ms);
                var sAddr  = result.AudioUrlInfo.AudioUrl.IP;
                var Port   = result.AudioUrlInfo.AudioUrl.Port;
                var url    = result.AudioUrlInfo.AudioUrl.Url;
                //取语音
                Dictionary <string, object> Headerdics = new Dictionary <string, object>()
                {
                    { "User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0; SM-G9009D Build/LRX21T" },
                    { "Content-Type", "application/x-www-form-urlencoded" },
                    { "Host", sAddr }
                };
                var res = HttpHelper.HttpClientGetAsync(url, Headerdics, API.mycookiecontainer, API.RedirectUrl).Result;
                return(res);
            }
            return("");
        }