我创建控制台应用程序,使用wget将数据从yammer导出到本地 第三方工具 这是参考 https://developer.yammer.com/docs/data-export-api
执行脚本的功能:
internal static bool ExecuteScript()
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
p = Process.Start(startInfo);
p.StandardInput.WriteLine("wget -O export.zip -t 1 --header \"Authorization: Bearer %Token%\" -ca-certificate cacert.pem https://www.yammer.com/api/v1/export?since=2016-02-09T00:00:00z");
p.StandardInput.WriteLine(@"exit");
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
p.Close();
Console.WriteLine("Error:" + error);
return true;
}
catch (Exception ex)
{
throw ex;
}
}
我用我的令牌替换%Token% 但是当运行代码时,它会切断下载并创建export.zip文件0KB 它不是下载完整的文件 它在控制台中显示此消息
虽然我将这个脚本放在批处理文件中并从同一路径中的cmd运行它,但它会下载完整的文件
注释: 1-我将Wget路径添加到路径环境 2-我正在使用Windows 10 3-我正在使用VS 2013
答案 0 :(得分:1)
我发现了问题
p.StandardInput.WriteLine("wget -O export.zip -t 1 --header \"Authorization: Bearer <Access Token>\" --ca-certificate=cacert.pem cacert.pem https://www.yammer.com/api/v1/export?since=2016-02-09T00:00:00z");