I am trying to fetch the data from a google docs spreadsheet and I think this should work (also seen similar code in another similar question on here) but the response I get is:
Moved Temporarily with the link to
The document has moved here.here being:
https://www.google.com/a/4playtheband.co.uk/ServiceLogin?service=wise&continue=https://docs.google.com/a/4playtheband.co.uk/spreadsheet/pub?hl%3Den_US%26hl%3Den_US%26key%3D0AuJb1YSvmVn5dGdvUzU2QUJHUGdaTEZNbVI4dVJ6eHc%26single%3Dtrue%26gid%3D0%26output%3Dcsv%26ndplr%3D1&followup=https://docs.google.com/a/4playtheband.co.uk/spreadsheet/pub?hl%3Den_US%26hl%3Den_US%26key%3D0AuJb1YSvmVn5dGdvUzU2QUJHUGdaTEZNbVI4dVJ6eHc%26single%3Dtrue%26gid%3D0%26output%3Dcsv%26ndplr%3D1&hl=en_US&passive=true&go=true
I don’t know if the problem is to do with the docs in question being used inside Google Apps but I have set the spreadsheet to be public and I copied the link it provided when I went to Share and exported it as a csv.
Here is the code:
<?php
$url='https://docs.google.com/a/4playtheband.co.uk/spreadsheet/pub?hl=en_US&hl=en_US&key=0AuJb1YSvmVn5dGdvUzU2QUJHUGdaTEZNbVI4dVJ6eHc&single=true&gid=0&output=csv';
if (($handle = fopen($url, "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$totalrows = count($data);
for ($row=0; $row<=$totalrows; $row++)
{
echo $data[$row];
}
}
fclose($handle);
}
?>
If it might be an issue I am actually trying to place the fetched data inside a facebox and it seems to be working except for the actual spreadsheet data not appearing since the error message I mentioned earlier actually appears inside the facebox.
Thanks.
UPDATE
The code seems to work perfectly fine when the spreadsheet is created within my personal google account and not the account that I use for Google Apps.
I managed to fix this by firstly using a spreadsheet inside my own google account and not google apps and by then using the following code: