本文整理汇总了C++中CFileCurl::Post方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileCurl::Post方法的具体用法?C++ CFileCurl::Post怎么用?C++ CFileCurl::Post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileCurl
的用法示例。
在下文中一共展示了CFileCurl::Post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallXmlRpc
//.........这里部分代码省略.........
}
if (title.IsEmpty())
{
CLog::Log(LOGERROR, "Last.fm CallXmlRpc no tracktitle provided.");
return false;
}
char ti[20];
time_t rawtime;
time ( &rawtime );
struct tm *now = gmtime(&rawtime);
strftime(ti, sizeof(ti), "%Y-%m-%d %H:%M:%S", now);
CStdString strChallenge = ti;
CStdString strAuth(strPassword);
strAuth.ToLower();
strAuth.append(strChallenge);
CreateMD5Hash(strAuth, strAuth);
//create request xml
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "" );
doc.LinkEndChild( decl );
TiXmlElement * elMethodCall = new TiXmlElement( "methodCall" );
doc.LinkEndChild( elMethodCall );
TiXmlElement * elMethodName = new TiXmlElement( "methodName" );
elMethodCall->LinkEndChild( elMethodName );
TiXmlText * txtAction = new TiXmlText( action );
elMethodName->LinkEndChild( txtAction );
TiXmlElement * elParams = new TiXmlElement( "params" );
elMethodCall->LinkEndChild( elParams );
TiXmlElement * elParam = new TiXmlElement( "param" );
elParams->LinkEndChild( elParam );
TiXmlElement * elValue = new TiXmlElement( "value" );
elParam->LinkEndChild( elValue );
TiXmlElement * elString = new TiXmlElement( "string" );
elValue->LinkEndChild( elString );
TiXmlText * txtParam = new TiXmlText( strUserName );
elString->LinkEndChild( txtParam );
elParam = new TiXmlElement( "param" );
elParams->LinkEndChild( elParam );
elValue = new TiXmlElement( "value" );
elParam->LinkEndChild( elValue );
elString = new TiXmlElement( "string" );
elValue->LinkEndChild( elString );
txtParam = new TiXmlText( strChallenge );
elString->LinkEndChild( txtParam );
elParam = new TiXmlElement( "param" );
elParams->LinkEndChild( elParam );
elValue = new TiXmlElement( "value" );
elParam->LinkEndChild( elValue );
elString = new TiXmlElement( "string" );
elValue->LinkEndChild( elString );
txtParam = new TiXmlText( strAuth );
elString->LinkEndChild( txtParam );
elParam = new TiXmlElement( "param" );
elParams->LinkEndChild( elParam );
elValue = new TiXmlElement( "value" );
elParam->LinkEndChild( elValue );
elString = new TiXmlElement( "string" );
elValue->LinkEndChild( elString );
txtParam = new TiXmlText( artist );
elString->LinkEndChild( txtParam );
elParam = new TiXmlElement( "param" );
elParams->LinkEndChild( elParam );
elValue = new TiXmlElement( "value" );
elParam->LinkEndChild( elValue );
elString = new TiXmlElement( "string" );
elValue->LinkEndChild( elString );
txtParam = new TiXmlText( title );
elString->LinkEndChild( txtParam );
CStdString strBody;
strBody << doc;
CFileCurl http;
CStdString html;
CStdString url = "http://ws.audioscrobbler.com/1.0/rw/xmlrpc.php";
http.SetMimeType("text/xml");
if (!http.Post(url, strBody, html))
{
CLog::Log(LOGERROR, "Last.fm action %s failed.", action.c_str());
return false;
}
if (html.Find("fault") >= 0)
{
CLog::Log(LOGERROR, "Last.fm return failed response: %s", html.c_str());
return false;
}
return true;
}