<?php

if ( !$user['admin'] ) {
    header("Location: https://bigtimberbuilders.com/clients/dashboard");
    exit;
}

//get attachment
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smartsheet.com/2.0/sheets/160662231666564/attachments/1624829275885444");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer qJc6jnLsHoqznwCbkApNwLMQamt6ITcykpgen", 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = json_decode(curl_exec($ch));
curl_close($ch);

echo "<pre>";
print_r($response);
echo "</pre>";

$file = file_get_contents($response->url);

// echo "<pre>";
// print_r($file);
// echo "</pre>";

// file_put_contents("/clients/assets/images/attachments/".$response->id."-".$response->name, $file);
file_put_contents('../assets/images/attachments/'.$response->id."-".$response->name, $file);

