Hi, story goes...

I need to process a timesheet - I want to use a csv file of the spreadsheet, so I was hoping to plug in the path to what Google said was a CSV output of a spreadsheet... https://spreadsheets0.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AhhCntOrEg9FdF9PZkIwY08tZTdwd3lkYkJFNEtkMkE&single=true&gid=1&output=csv

Unfortunately if you click on that link, it prompts you to download the file, instead of just printing out the plain text file (which I was hoping for)... I know there is a whole API for spreadsheets but its a headache and I want something easy-peasy...

How can I get a realtime dynamic csv file of my spreadsheet?

Thanks

you can try curl:

$URL = 'https://spreadsheets0.google.com/spr...d=1&output=csv';
$ch = curl_init(); // initialize the cURL session
curl_setopt($ch, CURLOPT_URL, $URL);  // tell it which URL to go to (minus the parameters)
curl_setopt($ch, CURLOPT_GET, 1);  // tell it that you want to send an HTTP GET request

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret_value = curl_exec ($ch); // do it
curl_close ($ch); // close the session   
    // $ret_value should be your csv response
    echo $ret_value;
    $pieces = explode(",",$ret_value);
    foreach($pieces as $piece) {

echo $piece;
} // end foreach

oh, there is no curlopt_get ( I had modified some of my code that I use for a post)
so:
CURLOPT_HTTPGET

and you don't have to set that in the first place unless it is returning other because a default curl request is 'GET' in the first place.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.