networkRequest

void TPHttp::applyResource()
{
    QJsonObject json;
    json.insert("ProductCode","MoVdoSource");
    json.insert("TempletType","");

    QJsonDocument document;
    document.setObject(json);
    QByteArray byte_array=document.toJson(QJsonDocument::Indented);
    QString str_1(byte_array);
    qDebug("apply source:\n%s",str_1.toStdString().c_str());

    request.setUrl(QUrl("http://mediax.sobeycache.com/version/getSoftLists"));
    // 设定请求头
//    request.setRawHeader("Host", "mediax.sobeycache.com");
//    request.setRawHeader("Content-Length",QString::number(byte_array.size()).toStdString().c_str ());
    request.setRawHeader("Accept-Charset", "UTF-8");
    request.setRawHeader("Content-type","text/plain");
    request.setRawHeader("Connection", "keep-alive");

    reply=manager->put(request,byte_array);
    connect(reply, SIGNAL(readyRead()),
            this, SLOT(applyReady()));
}
void TPHttp::applyReady()
{
    QByteArray recData=reply->readAll();

    QJsonParseError json_error;
    QJsonDocument parse_doucment = QJsonDocument::fromJson(recData, &json_error);
    QString str_1(recData);
    qDebug("apply resources:\n%s",str_1.toStdString().c_str());

//    if(json_error.error == QJsonParseError::NoError)
//    {
//        if(parse_doucment.isObject())
//        {
//            QJsonObject obj = parse_doucment.object();
//            if(obj.contains("code"))
//            {
//                QJsonValue code_value = obj.take("code");
//                double dcode;QString str_mess;
//                if(code_value.isDouble())
//                {
//                    dcode=code_value.toDouble();
//                    str_mess.setNum(dcode,'g');
//                    //                         QString("delta: %1").arg(d, 0, 'E', 3);
//                }
//                else if(code_value.isString())
//                {
//                    str_mess=code_value.toString();
//                }
//                if(!str_mess.compare("0"))
//                {
//                    qDebug("success login");
//                    genelogfile(m_usrname,m_password);
//                    m_bLogined=true;
//                    emit bLoginedChanged(m_bLogined);
//                }
//                else
//                {
//                    if(!str_mess.compare("10001"))
//                        qDebug("password and user are error");
//                    else if(!str_mess.compare("10003"))
//                        qDebug("Don't have this user");
//                    else if(!str_mess.compare("10004"))
//                        qDebug("password is error");
//                    m_bLogined = false;
//                    //                        emit bLoginedChanged(m_bLogined);
//                }
//            }
//        }
//    }
}

 

 

 

Section IV MoVdo resource query interface

 


 

  1. Call address of the interface

 

http://mediax.sobeycache.com/version/getSoftLists

 


 

  1. Features

 

Get magic beans list of resources, according to the template type ( TempletType filtering query), do not fill the template type represents a query for all resources.

 


 

  1. Called

 

HTTP POST

 


 

  1. parameter

 

  • Sample parameters

 

{

 

"ProductCode" : "MoVdoSource",

 

"TempletType": " Subtitle Template "

 

}

 

  • Parameter Description

 

The ProductCode : required, fixed here to fill MoVdoSource ,

 

TempletType : Optional, according to the VBOSS filtered version of the resource type when creating a new set; when not fill data, query the resources of all the Beanstalk

 


 


 


 

  1. Interface call returns data

 

Interface After the call is successful, return the following format JSON data:

 

{

 

"status" : 1,

 

"result" : "",

 

"soft_list" : [

 

{

 

"id" : "30",

 

"product_id" : "10",

 

"product_code" : "MoVdoSource",

 

"inside_version" : "100",

 

"templet_type": " Subtitle template "

 

"versionname" : "主题",

 

"description" : "测试",

 

"version" : "1.0",

 

"filepath" : "http://api.vboss.sobey.com/static/Setup/dxwebsetup.exe",

 

"iconpath" : "http://api.vboss.sobey.com/static/Setup/Media10_1.0.0_icon.png",

 

"filesize" : "1",

 

"md5code" : "36A5D102EF30A2CA60200362F8ABB122",

 

"modified" : "2015-07-31 14:47:31"

 

}

 

]

 

}

 


Fifth, the interface calls the error CODE and its meaning

When you call VBOSS user interfaces registry error, also returns JSON data, then JOSN the code is non-zero number, for example:

{

"code" : "10002",

"msg": " the lack of appropriate parameters ."

}


Note: code information corresponding to the value as follows:

0: Successful operation

00001: network anomalies

00002: Response Timeout

00003: database operation failed

00004: parameter illegal


10001: username and password do not match

10002: lack of appropriate parameters

10003: check there is no user

10004: wrong password

10005: pin values are incorrect

10006: Username / E-mail / phone number has been registered

10007: User name has been registered

10008: mailbox has been registered

10009: phone number has been registered


50001: encryption / decryption of data is empty or invalid


 

Published 90 original articles · won praise 26 · Views 100,000 +

Guess you like

Origin blog.csdn.net/sky_person/article/details/50133383