• c# 微软小冰-虚拟女友聊天


    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TestXiaobingChat
    {
        public class HttpHelper
        {
    
            public static string Cookie = Properties.Resources.cookie ;
            public  static  string HttpPost(string Url, string postDataStr,bool jsonPost=false )
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                request.Method = "POST";
                // request.ContentType = "application/x-www-form-urlencoded";
                //application/json;charset=UTF-8
                request.ContentType = "application/x-www-form-urlencoded";
                if (jsonPost) 
                {
                    request.ContentType = "application/json";
                }
                byte[] postData = Encoding.UTF8.GetBytes(postDataStr);
                request.ContentLength = postData.Length;
                request.Referer = "https://ux-plus-bing.xiaoice.com/BingVirtualGF?authcode=51E6AE30F8FABC23FAF64F73A102BC9F";
               // request.CookieContainer = cc;
                request.Headers.Add("cookie",Cookie);
                Stream myRequestStream = request.GetRequestStream();
                myRequestStream.Write(postData, 0, postData.Length);
                myRequestStream.Close();
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
               // response.Cookies = cookie.GetCookies(response.ResponseUri);
                Stream myResponseStream = response.GetResponseStream();
                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
                string retString = myStreamReader.ReadToEnd();
                myStreamReader.Close();
                myResponseStream.Close();
    
                return retString;
            }
    
            public static  string HttpGet(string Url)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                request.Method = "GET";
                request.ContentType = "text/html;charset=UTF-8";
                request.Headers.Add("cookie", Cookie);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream myResponseStream = response.GetResponseStream();
                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
                string retString = myStreamReader.ReadToEnd();
                myStreamReader.Close();
                myResponseStream.Close();
    
                return retString;
            }
    
    
        }
        
    
    }
    

      

     private void Button_Click(object sender, RoutedEventArgs e)
            {
    
                HttpHelper.HttpPost("https://ux-plus-bing.xiaoice.com/s_api/game/getresponse?workflow=AIBeingsBingGFChat", Properties.Resources.para ,true );
    
            }
    

      

    para= {"TraceId":"15ee7bcc2310cefe2ef196df9599f44ad","PartnerName":"bingaibeings","SubPartnerId":"virtualgf","Content":{"Text":"在干嘛","Metadata":{}}}

    fffffffffffffffff
    test red font.
  • 相关阅读:
    团队作业第五次—项目冲刺-Day6
    团队作业第五次—项目冲刺-Day4
    团队作业第五次—项目冲刺-Day3
    团队作业第五次—项目冲刺-Day2
    研途——冲刺集合
    团队作业第六次—事后诸葛亮
    研途——测试总结
    研途——冲刺总结
    研途——冲刺日志(第七天)
    研途——冲刺日志(第六天)
  • 原文地址:https://www.cnblogs.com/wgscd/p/15433517.html
Copyright © 2020-2023  润新知