I have created a google spreadsheet and use google visualization API
to access the data and pick up a single row and display it. It works
fine when my browser is logged google account but when it is not then
it gives an access denied error.
I have published the spreadsheet and made it viewable by all. I can
view the spreadsheet without logging in gmail account:
http://spreadsheets.google.com/pub?key=pkv_7X5t9HXVu4ZxZ-znSEA
Following is the code:
--------------------------------
<table bgcolor="black">
<tbody><tr>
<td><span style="color: rgb(0, 255, 0);">root@matrix:>
<div id="quote"> </div>
<script src="
http://www.google.com/jsapi" type="text/javascript"></
script>
<script type="text/javascript">
google.load("visualization", "1");
function initialize() {
var query = new google.visualization.Query("http://
spreadsheets.google.com/tq?key=pkv_7X5t9HXVu4ZxZ-znSEA&gid=0");
query.send(handleQueryResponse); // Send the query with a
callback function
}
google.setOnLoadCallback(initialize); // Set callback to run
when API is loaded
// Query response handler function.
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' +
response.getDetailedMessage());
return;
}
var data = response.getDataTable();
var html = [];
var rows = data.getNumberOfRows();
var index = parseInt ("" + Math.random() * rows + "" );
html.push (data.getFormattedValue (index,0));
document.getElementById('quote').innerHTML = html.join('');
}
</script>
</span><img width="20" src="
http://prateek.mac.googlepages.com/
blinking_cursor2.gif" height="16"/>
</td>
</tr>
</tbody></table>