json
{
"data": {
"acct": [
{
"maxaddons": "1",
"ip": "192.168.0.20",
"ipv6": ["0101:ca75:0101:ca75:0101:ca75:0101:ca77"],
"outgoing_mail_suspended": 0,
"outgoing_mail_hold": 0,
"min_defer_fail_to_trigger_protection": 5,
"legacy_backup": 0,
"diskused": "0M",
"maxftp": "2",
"startdate": "13 Jul 08 14:33",
"max_defer_fail_percentage": "10",
"disklimit": "100M",
"is_locked": "0",
"suspendtime": null,
"email": "",
"domain": "example.com",
"unix_startdate": 1373312011,
"user": "example",
"plan": "plan9",
"shell": "\/bin\/bash",
"maxpop": "20",
"backup": 0,
"theme": "paper_lantern",
"owner": "root",
"max_email_per_hour": "100",
"suspendreason": "not suspended",
"maxlst": "5",
"suspended": 0,
"maxsql": "1",
"maxparked": "1",
"partition": "home",
"maxsub": "5"
},
]
},
"metadata": {
"version": 1,
"reason": "OK",
"result": 1,
"command": "listaccts"
}
}
//controller
public function ApiAction()
{
$Cpanel = new \Gufy\CpanelPhp\Cpanel;
$Cpanel->setAuthType('hash');
$Cpanel->setHost($this->container->getParameter('api_host'));
$Cpanel->setAuthorization($this->container->getParameter('api_user'), $this->container->getParameter('api_hash'));
$Cpanel->setTimeout(50);
$Arguments = array();
$QueryCpanel= $Cpanel->__call('listaccts', $Arguments);
$em = $this->getDoctrine()->getEntityManager();
$json = json_decode($QueryCpanel, true);
foreach ($json as $List) {
$Data['Domain'] =$List ['domain'];
$Data['IP'] = $List ['ip'];
$Data['UserName'] = $List ['user'];
$Data['Email'] = $List ['email'];
$Data['StartDate'] = $List ['startdate'];
$Data['DiskPartition'] = $List ['partition'];
$Data['Quota'] = $List ['disklimit'];
$Data['DiskSpaceUsed'] = $List ['diskused'];
$Data['Package'] = $List ['plan'];
$Data['Theme'] = $List ['theme'];
$Data['Owner'] = $List ['owner'];
$Data['UnixStartDate'] = $List ['unix_startdate'];
$em->getRepository('AppBundle:Listaccts')
->InsertListaccts('listaccts', $Data);
}
Iam trying to insert data from api to database and I keep getting error Notice: Undefined index: domain
If refresh my browser then I get this error
An exception occurred while executing 'INSERT INTO (Domain, IP, UserName, Email, StartDate, DiskPartition, Quota, DiskSpaceUsed, Package, Theme, Owner, UnixStartDate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [null, null, null, null, null, null, null, null, null, null, null, null]:
I also tried with controller persist I got same error there. I dont know what iam doing wrong.