Public Member Functions | |
codesAction () |
Definition at line 35 of file IndexController.php.
codesAction | ( | ) |
Retrieve js scripts by parsing remote Google Optimizer page
Definition at line 40 of file IndexController.php.
00041 { 00042 if ($this->getRequest()->getQuery('url')) { 00043 $client = new Varien_Http_Client($this->getRequest()->getQuery('url')); 00044 $response = $client->request(Varien_Http_Client::GET); 00045 $result = array(); 00046 if (preg_match_all('/<textarea[^>]*id="([_a-zA-Z0-9]+)"[^>]*>([^<]+)<\/textarea>/', $response->getRawBody(), $matches)) { 00047 $c = count($matches[1]); 00048 for ($i = 0; $i < $c; $i++) { 00049 $id = $matches[1][$i]; 00050 $code = $matches[2][$i]; 00051 $result[$id] = $code; 00052 } 00053 } 00054 $this->getResponse()->setBody( Zend_Json::encode($result) ); 00055 } 00056 }