ฉันสร้างแอปพลิเคชันคอนโซลที่ส่งออกข้อมูลจาก yammer ไปยังเครื่องโดยใช้เครื่องมือบุคคลที่สาม wget และนี่คือข้อมูลอ้างอิง 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 ไปยัง Path Environment 2- ฉันใช้ windows 10 3- ฉันใช้ VS 2013