Ejemplo n.º 1
0
        internal ShareInfo Share(NnFile file, string key)
        {
            HttpWebRequest request = WebRequest.CreateHttp($"https://pan.baidu.com/share/set?channel=chunlei&clienttype=0&web=1&channel=chunlei&web=1&app_id=250528&bdstoken=&logid=&clienttype=0");

            request.KeepAlive       = true;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded; charset=UTF-8";
            request.CookieContainer = m_cookie;
            request.Host            = "pan.baidu.com";
            request.UserAgent       = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362";
            request.Accept          = "*/*";

            string flist = System.Web.HttpUtility.UrlEncode($"[{file.PanFile.fs_id}]");
            string clist = System.Web.HttpUtility.UrlEncode("[]");

            byte[] bytes = Encoding.UTF8.GetBytes($"channel_list={clist}&fid_list={flist}&period=7&pwd={key}&schannel=4");
            request.ContentLength = bytes.Length;
            Stream stream = request.GetRequestStream();

            stream.Write(bytes, 0, bytes.Length);
            stream.Close();

            WebResponse  response  = request.GetResponse();
            StreamReader reader    = new StreamReader(response.GetResponseStream());
            string       resstring = reader.ReadToEnd();

            response.Close();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ShareInfo            info       = serializer.Deserialize <ShareInfo>(resstring);

            return(info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 分享
        /// </summary>
        private void _shear()
        {
            List <NnFile> list = _getSelectedItems();
            StringBuilder sb   = new StringBuilder();

            foreach (var v in list)
            {
                if (v.PanFile.isdir == 1)
                {
                    sb.Append(v.PanFile.server_filename).Append("\t是文件夹,无法分享\n");
                    continue;
                }
                try
                {
                    ShareInfo info = mPanManagers[v.AccountId].Share(v, "ersf");

                    if (info.error != 0)
                    {
                        sb.Append(v.PanFile.server_filename).Append("\t").Append("分享错误\n");
                    }
                    else
                    {
                        sb.Append(v.PanFile.server_filename).Append("\t").Append("连接:").Append(info.link).Append(" 提取码:ersf\n");
                    }
                    Console.WriteLine(info.createsharetips_ldlj);
                }catch (Exception e) { Console.WriteLine(e.ToString()); }
            }
            Clipboard.SetText(sb.ToString());
            WarnWindow.ShowMessage("分享信息已复制到剪贴板!\n" + sb.ToString());
        }