简体   繁体   English

cUrl命令C ++代码替换

[英]cUrl command C++ code replacement

我有这个cUrl命令,需要在Linux下的C ++程序中执行,我正在使用Qt方式并包括libcUrl,我需要知道与该cUrl命令相当的确切方法调用:

curl -d 'grant_type=client_credentials&client_id=mdme2323&client_secret=asdaeqwedsa24124ewesiou&scope=http://api.microsofttranslator.com' https://datamarket.accesscontrol.windows.net/v2/OAuth2-13 | python -m json.tool

What about execute the command in a new process? 在新进程中执行命令呢?

QString cmd("curl -d 'grant_type=client_credentials&client_id=mdme2323&client_secret=asdaeqwedsa24124ewesiou&scope=http://api.microsofttranslator.com' https://datamarket.accesscontrol.windows.net/v2/OAuth2-13 | python -m json.tool");
QProcess::execute(cmd);

Here is how I fixed it: 这是我的解决方法:

QProcess* proc = new QProcess();
QString cmd( "/bin/sh" );
QStringList args;
args << "-c" << "curl -d 'grant_type=client_credentials&client_id=islam123&client_secret=23ewsed323we2ewesiou&scope=http://api.microsofttranslator.com' https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
proc->execute(cmd, args);
data = proc->readAll();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM