Accessing google docs spreadsheet revisited in 2014

喜欢而已 提交于 2019-12-11 11:17:06

问题


I am trying to access a google spreadsheet through php (by adding &output=csv to the link) It seems like google does not want this any more, is this correct? I tried file_get_contents (and yes, allow_url_fopen is turned on,) which results in an error. When using CURL, even when setting a valid user agent (I used Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13) I get a notice that the file has temporarily moved. The link I am using works fine with accessing the spreadsheet from a browser. I tried setting the spreadsheet to public from within google docs, to no avail.

Solutions suggested here, here and here don't seem to work any more. If google does not want me to do this I won't keep trying, but I haven't found anything supporting that. In the comments of some page I read something about gData ZendFramework, but would like to avoid anything that is not deployed to a standard LAMP server.

PS: I am not trying to abuse google by leeching their bandwidth. I wrote a conversion script for csv files, and in addition to file upload for conversion I was hoping to integrate with google docs links.


回答1:


Make sure the spreadsheet is publicly accessible, and published to the web by selecting "publish to the web" from the File menu.

Copy the link and view it in your browser to check it works. Then replace /pubhtml at the end of the URL with /export?format=csv&id and voila! Well it worked for me.

See https://productforums.google.com/forum/#!topic/docs/An-nZtjaupU



来源:https://stackoverflow.com/questions/22819484/accessing-google-docs-spreadsheet-revisited-in-2014

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!