Skip to content

Instantly share code, notes, and snippets.

@rewfergu
Created November 30, 2012 21:48
Show Gist options
  • Save rewfergu/4178919 to your computer and use it in GitHub Desktop.
Save rewfergu/4178919 to your computer and use it in GitHub Desktop.
Import contents of a Google Doc into a page
<?php
// Based on http://www.realisingdesigns.com/2009/10/29/using-google-docs-as-a-quick-and-easy-cms/
// Specify document ID
$gd_doc = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$gd_array = array();
$gd_array["url"] = "https://docs.google.com/document/pub?id=".$gd_doc;
$gd_array["start"] = '<div id="contents">';
$gd_array["end"] = '<div id="footer">';
$working_doc = file_get_contents($gd_array["url"]);
$gd_start = strpos($working_doc,$gd_array["start"]);
$gd_end = strpos($working_doc,$gd_array["end"]);
$gd_content = substr($working_doc, $gd_start, ($gd_end-$gd_start) )
?>
<?=$gd_content?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment