Bogdan Tanase
Member
Hi everyone,
I want to expose an API from a custom module, so I've created a new controller with the actions I need but I'm a bit puzzled about the appropriate way to ouput the needed data in JSON format.
Do I need to create a separate view just for this or there's some nice helper in the Xenforo library?
I want to expose an API from a custom module, so I've created a new controller with the actions I need but I'm a bit puzzled about the appropriate way to ouput the needed data in JSON format.
Do I need to create a separate view just for this or there's some nice helper in the Xenforo library?
PHP:
class MyModule_ControllerPublic_Chat extends XenForo_ControllerPublic_Abstract {
public function actionIndex()
{
$data = array('example_key' => 'example_value');
$json = json_encode($data);
// something like this would be nice :)
// return $this->responseJson($json);
}
}
Last edited: