public function testObtener() { $autorization = sprintf("BASIC + window.btoa(%s + :xxx)", "asdasdasdas"); $options = array('body' => array(), 'config' => array(), 'headers' => array()); $tag = new Tag(); $tag->__set("apiKey", "cat952yellow"); $tag->obtener(); $response = $tag->__get("response"); error_log(print_r($response, true)); $this->assertTrue($response['status'] == 'exito'); $this->assertGreaterThan(count($response['body']), 0); }
public function obtener() { try { $compania = new Tag(); $compania->__set("apiKey", APIKEY_); $this->log->addInfo("Inicio flujo de Tag", array(basename(__FILE__) . "::" . __LINE__)); $compania->obtener(); $response = $compania->__get("response"); if ($response['status'] == "exito" && count($response['body']) > 0) { $this->log->addInfo("Respuesta de api exitosa", array(basename(__FILE__) . "::" . __LINE__)); $values = array(); $pdo = new \Slim\PDO\Database(BD_DNS_, BD_USER_, BD_PWD_); //Conexion::getInstance(); foreach ($response['body'] as $key => $value) { $keys = array(); $insertValue = array(); foreach ($value as $keyB => $valueB) { array_push($keys, $keyB); array_push($insertValue, empty($valueB) || $valueB == '' ? 'null' : $valueB); } $this->log->addInfo(print_r($keys, true), array(basename(__FILE__) . "::" . __LINE__)); $this->log->addInfo(print_r($insertValue, true), array(basename(__FILE__) . "::" . __LINE__)); $insertStatement = $pdo->insert($keys)->into('lkp_tags')->values($insertValue); $insertId = $insertStatement->execute(); } } else { $this->log->addInfo("Sin recursos encontrados", array(basename(__FILE__) . "::" . __LINE__)); } } catch (PDOException $e) { $this->log->addError("PDOException", array(basename(__FILE__) . "::" . __LINE__)); $this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__)); } catch (\Exception $e) { $this->log->addError(" ", array(basename(__FILE__) . "::" . __LINE__)); $this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__)); } }