public function testObtener() { $autorization = sprintf("BASIC + window.btoa(%s + :xxx)", "asdasdasdas"); $options = array('body' => array(), 'config' => array(), 'headers' => array()); $project = new Project(); $project->__set("apiKey", "cat952yellow"); //var_dump($project -> __get("response")); $project->obtener(); error_log(print_r(json_encode($project->__get("response")), true)); }
public function obtener() { try { $compania = new Project(); $compania->__set("apiKey", APIKEY_); $this->log->addInfo("Inicio flujo de Project", 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); } $insertValue[8] = $value->company['id']; $keys[8] = 'companyId'; $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_projects')->values($insertValue); $insertId = $insertStatement->execute(); $this->insertRel($value); } } 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__)); } }