Skip to content

Instantly share code, notes, and snippets.

@yumyo
Forked from rdlagency/google-doc-cms-test.php
Created August 27, 2019 15:26
Show Gist options
  • Save yumyo/b0c89c78193946ce776c089da22c90c7 to your computer and use it in GitHub Desktop.
Save yumyo/b0c89c78193946ce776c089da22c90c7 to your computer and use it in GitHub Desktop.
<?php
// This was a quick proof of concept from 2009, use the script freely - https://www.realisingdesigns.com/web-design-articles/using-google-docs-quick-easy-cms/
// Specify document
$gd_doc = "dd9zpc9r_4jh8qv76j";
$gd_doc_type = "doc";
$gd_array = array();
$gd_array["doc"]["url"] = "http://docs.google.com/View?id=".$gd_doc;
$gd_array["doc"]["start"] = '&lt;div id="doc-contents"&gt;';
$gd_array["doc"]["end"] = '&lt;div id="google-view-footer"&gt;';
$working_doc = file_get_contents($gd_array[$gd_doc_type]["url"]);
$gd_start = strpos($working_doc,$gd_array[$gd_doc_type]["start"]);
$gd_end = strpos($working_doc,$gd_array[$gd_doc_type]["end"]);
$gd_content = substr($working_doc, $gd_start, ($gd_end-$gd_start) );
// Output
echo $gd_content;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment