void GetRequest::exec(AbstractWeiboApi *apiRequest) { QByteArray responseStr; if (apiRequest->isHttpGet()) responseStr = manager->getMethod(apiRequest->getUrl()); else { QHttpMultiPart multiPart(QHttpMultiPart::FormDataType); QList<QHttpPart> partList = apiRequest->setPostMultiPart(); for (int i = 0; i < partList.size(); i++) multiPart.append(partList.at(i)); responseStr = manager->postMethod(apiRequest->getUrl(), multiPart); } QString error; JsonParser parser(responseStr); QJsonObject responseMap = parser.getJsonObject(); if (responseMap.isEmpty()) error = responseStr; else error = apiRequest->parse(responseMap); if (responseMap.find("error") != responseMap.end()) error = responseStr; emit sendLog(apiRequest->getUrl().toString(), QDateTime::currentDateTime(), responseMap, error); }
void sendEmailAttachData(const char * to, const char * subject, const char * body, size32_t lenAttachment, const void * attachment, const char * mimeType, const char * attachmentName, const char * mailServer, unsigned int port, const char * sender, StringArray *warnings) { CMailInfo info(to, subject, mailServer, port, sender, warnings); CTextMailPart inlinedPart(body, "text/plain; charset=ISO-8859-1", NULL); CDataMailPart attachmentPart(lenAttachment, attachment, mimeType, attachmentName); CMultiMailPart multiPart(inlinedPart, attachmentPart); doSendEmail(info, multiPart); }