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":{}}}
c# 微软小冰-虚拟女友聊天的更多相关文章
- Hexo之我的桌角女友的食用方式
秀秀 通过使用一个名为 hexo-helper-live2d 的开源库,可以轻松的在自己的Hexo网站下贴上一只生猛可爱的萌妹子或主子: 什么是live2d Live2d是11区宅男们开发出的虚拟女友 ...
- IM即时通讯:如何跳出传统思维来设计聊天室架构?
因为视频直播业务的大规模扩张,聊天室这种功能在最近几年又火了起来.本篇文章将会重点挑选聊天室这个典型场景,和大家分享一下网易云信在实现这个功能时是如何做架构设计的. 相关推荐阅读几十万人同时在线的直播 ...
- 使用 Visual Studio Online 进行协同开发
Visual Studio Online(原来的 Team Foundation Service),是项目数据在云中的主页.在我们的云基础架构中只需数分钟便可启动并运行,无需安装或配置任何服务器.设置 ...
- JS学习知我见(常用建站代码)
<!doctype html><html><head><meta charset="utf-8"><meta name=&qu ...
- 我的第一个python web开发框架(41)——总结
我的第一个python web开发框架系列博文从17年6.7月份开始写(存了近十章稿留到9月份才开始发布),到今天结束,一年多时间,想想真不容易啊. 整个过程断断续续,中间有段时间由于工作繁忙停了好长 ...
- Stable Diffusion魔法入门
写在前面 本文为资料整合,没有原创内容,方便自己查找和学习, 花费了一晚上把sd安装好,又花了大半天了解sd周边的知识,终于体会到为啥这些生成式AI被称为魔法了,魔法使用前要吟唱类比到AI上不就是那些 ...
- Python练习2-基本聊天程序-虚拟茶会话
基本聊天程序 先来个基本的测试例子: Main.py from asyncore import dispatcher import socket,asyncore PORT = 11223 class ...
- c++实现中介者模式--虚拟聊天室
内容: 在"虚拟聊天室"实例中增加一个新的具体聊天室类和一个新的具体会员类,要求如下: 1. 新的具体聊天室中发送的图片大小不得超过20M. 2. 新的具体聊天室中发送的文字长度不 ...
- 情人节用Python智能聊天机器人的实现|制作一个虚拟恋人
首先项目需要的包 import urllib.request import urllib.parse from tkinter import * import time PS:另外很多人在学习Pyth ...
- Android—简单的仿QQ聊天界面
最近仿照QQ聊天做了一个类似界面,先看下界面组成(画面不太美凑合凑合呗,,,,):
随机推荐
- Git Flow开发分支管理
Git Flow Git Flow 是一种基于 Git 版本控制系统的分支管理模型,定义了一套严格的分支命名和操作规范 主要包括以下几种分支类型: 主干分支(master):始终保持稳定,只包含经过充 ...
- Codeforces 983 A-E
题解 A 难度:黄 算法标签:数学.进制 题目翻译:给定进制 \(b\) 和分数 \(\frac{p}{q}\),求这个分数在 \(b\) 进制下是否是有限小数. 题目分析: 首先将分数化简(不用说了 ...
- MySQL无开通SQL全审计下的故障分析方法
几年前MySQL数据库出现突然的从库延迟故障和CPU爆高时,如何排查具体原因,可能说已在腾讯云的MySQL库里开启了SQL全审计,记录了全部执行的SQL,再通过下面的方法就可以很容易找到原因: 1,实 ...
- delphi Image32 SVG图形查看器
DELPHI 中没有SVG显示组件,需要用到第三方组件,高版本可以使用skia(但必须带上skia.dll). 最新版Image32修改了很多,SVGIconImageList 也因此换成了Image ...
- core-js版本过低,需要更新但是更新失败的原因
ore-js@2.6.12: core-js@.3 is no longer maintained and not recommended for usage due to the number of ...
- Impala学习--代码生成(Code Generation)
代码生成 (Code Generation) Table of Contents 1 概述 2 为何使用代码生成 3 llvm 4 Impala使用IR 5 示例 6 总结 1 概述 Cloudera ...
- ContosoRetailDW数据库恢复问题
https://www.microsoft.com/en-us/download/details.aspx?id=18279 下载 ContosoBIdemoBAK.exe和ContosoBIdemo ...
- FileSaver 文件导出
1.前言 本节主要讲述如何将后台返回的JSON以文件的形式保存到本地 官方文档 兼容性(转载) Browser Constructs as Filenames Max Blob Size Depend ...
- Asp.net MVC,屏蔽类属性
将一个类序列化成JSON或XML时,如果某个字段或属性不想被序列化,一般可以使用以下注解: 1.[Newtonsoft.Json.JsonIgnore]特性:使用Newtonsoft.Json序列化时 ...
- Excel使用IF{1,0}虚拟数组+VLOOKUP实现联合查询
以此案例举例: 使用IF({1,0})建立虚拟数据的方法,整体输入的公式是: =VLOOKUP(E2&F2,IF({1,0},A:A&B:B,C:C),2,0) 输入完公式之后,需要按 ...