Ejemplo n.º 1
0
 /**
  * Check if survey url valid (exists) or not
  *
  * @return bool
  */
 public function isSurveyUrlValid()
 {
     $curl = new \Magento\Framework\HTTP\Adapter\Curl();
     $curl->setConfig(array('timeout' => 5))->write(\Zend_Http_Client::GET, $this->getSurveyUrl(), '1.0');
     $response = $curl->read();
     $curl->close();
     if (\Zend_Http_Response::extractCode($response) == 200) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Retrieve feed data as XML element
  *
  * @return \SimpleXMLElement
  */
 public function getFeedData()
 {
     $curl = new \Magento\Framework\HTTP\Adapter\Curl();
     $curl->setConfig(array('timeout' => 2));
     $curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
     $data = $curl->read();
     if ($data === false) {
         return false;
     }
     $data = preg_split('/^\\r?$/m', $data, 2);
     $data = trim($data[1]);
     $curl->close();
     try {
         $xml = new \SimpleXMLElement($data);
     } catch (\Exception $e) {
         return false;
     }
     return $xml;
 }