0
CakePHP 웹 애플리케이션을 원격 안정 서버에 연결하는 특정 작업이 있습니다. 데이터 소스를 만들고 메서드 읽기는 훌륭하지만 데이터 저장 후 API는 처리 된 데이터 배열을 반환합니다.CakePHP 2.5 데이터 소스, 응답 생성 및 응답
데이터 배열을 반환하고 컨트롤러에서 사용하는 방법을 찾고 있습니다. 데이터 소스 파일에서
내 컨트롤러 코드
public function admin_generate()
{
$data = $this->request->data;
$data['path'] = 'special/generate';
$this->Tool->create();
if($this->Tool->save($data)){
// handle response ????
}
$this->set('data',$data);
$this->set('_serialize','data');
}
는
public function create(Model $model, $fields = null, $values = null)
{
$data = array_combine($fields, $values);
$api = $this->config['api_path'].$data['path'].'?auth_key='.$this->config['auth_key'];
$json = $this->Http->post($api, $data);
$response = json_decode($json, true);
if (is_null($response)) {
$error = json_last_error();
throw new CakeException($error);
}
return $response; // ??????
}
은 누군가가 나에게 컨트롤러에서 API 응답 데이터를 사용하는 올바른 방법을 게재 할 수 있습니까?