DIY – Getting Started

[insert_php]
$url = “https://docs.google.com/document/d/1mXFcxk5NsxRNgmA4Y6Glxk0J3Q_xKGeUXm81QAFJAmo/pub?embedded=true”;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);

$myRegex = ‘/\=(.*?)\&/’;
$myGoogle = “https://docs.google.com/document/d/”;

$DOM = new DOMDocument;
$DOM->loadHTML( $output);

$items = $DOM->getElementsByTagName(‘img’);
for ($i = 0; $i < $items->length; $i++)
{
$myImage = $items->item($i)-> getAttribute(‘src’) ;
$pos = strpos($myImage, “pubimage”) ;
if ($pos !== false)
{
$myString = preg_match($myRegex, $myImage, $matches);
$myReplace = $myGoogle . $matches[1] . “/” . $myImage;
$items->item($i)-> setAttribute(‘src’,$myReplace);
}
}

echo $DOM->saveXML();
curl_close($curl);
[/insert_php]


Next up, Mounting Components