QT Call Simsimi API realizes small yellow chicken

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.