Project Address: Https://github.com/racaljk/xiaojianji
Okay, I'll name it a little chicken. And here's what he's doing.
Because the official Simsimi API charges, the free trial version has various restrictions, so here use the www.xiaohuangji.com then Post implementation, the UI interface has a LINEEDIT message input box, a textedit to display, A pushbutton sends a message
Xiaojainji.cpp
Use www.xiaohuangji.com for postvoid xiaojianji::on_pushbutton_clicked () {QString str = ui->lineedit->text (); Ui->textedit->append ("I:" + str+ "\ n"); Display Message ui->lineedit->clear () in TextEdit; After sending, clear the Linedit text Qtextcodec *utf8 = qtextcodec::codecforname ("Utf-8"); Qbytearray msg = "para=" + utf8->fromunicode (str). topercentencoding (); Last Post msg qnetworkrequest request; Request.setheader (Qnetworkrequest::contenttypeheader, "application/x-www-form-urlencoded"); Header Request.setheader (Qnetworkrequest::contentlengthheader,msg.length ()); Request.seturl (Qurl ("http://www.xiaohuangji.com/ajax.php")); Qnetworkreply *reply = Manager->post (request,msg); Post}void xiaojianji::replyfinished (qnetworkreply *reply) {if (reply->error () = = Qnetworkreply::noerror) {Q String out (Reply->readall ()); Accept Post Data Ui->textedit->append ("Small base chicken:" + out + "\ n"); Show}else{ui->textedit-> in TextEditAppend ("Little chicken: There seems to be something wrong ... \ n"); }}
As simple as this, it would be easier to use PHP ...
QT Call Simsimi API realizes small yellow chicken