i want to save a smartsheet to my server (as .xls). But i always get an .xls filled with json-code. I get the "file_put error" if i use json_decode(..) and the .xls is completely empty. If i do it via curl on my desktop i get the right .xls filled with everything i need.
$baseURL = "https://api.smartsheet.com/1.1";
$headers = array("Authorization: Bearer ".$inputToken);
.
.
array_push($headers,'"Accept: application/vnd.ms-excel" -o tmpfile.xls --insecure');
$curlSession = curl_init($sheetDetail_url);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
$smartsheetData = curl_exec($curlSession);
if (curl_errno($curlSession))
{
echo "Oh No! Error: " . curl_error($curlSession);
}else{
// Assign response to PHP object
$sheetsObj = json_decode($smartsheetData);
// close curlSession
curl_close($curlSession);
}
$file1="tmpfile.xls";
if(!(file_put_contents($file1, $sheetsObj))){
echo "file_put error";
}
I hope you can help me. Thanks