I have given a code that I makes me a bit confused. If I go to my url, it gets me a error of trying to get property...
and when i use dd
for the $response
it says null. Can someone tell me what should I do and why I always get this error? I know this error occur because the $response
variable does not have and status
object? Am I right? but when I dd $response
it says null
. Thanks in advance
My controller
public function pingDomain(Request $request){
$host = $request->staging == 1 ? env('PROPNEX_IP') : env('PROPNEX_IP_PROD');
$url = $host. '/propnex/index.php/domain/Ping_domain?domain='.urlencode($request->domain).'&host_ip='.$request->ip;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch,CURLOPT_HTTPHEADER,[
'Content-type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch));
// dd($response);
//ERROR IS HERE IN IF STATEMENT
if ($response->status == 0){
$host = $request->staging == 1 ? env('PROPNEX_IP') : env('PROPNEX_IP_PROD');
$url = $host . '/propnex/index.php/pnapi/addDomain?type=own&domain='.$request->domain. '&site-id='. $request->siteid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch,CURLOPT_HTTPHEADER,[
'Authentication: '.$request->agentid . ':'. $request->auth
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch));
curl_close($ch);
if($response->status == "ok"){
return redirect()->route('ping-domain-success',[
"fname" => $request->fname,
"lname" => $request->lname,
"agentid" => $request->agenatid,
"auth" => $request->auth,
"email" => $request->email,
"prtname" => $request->prtname,
"cea"=> $request->cea,
"type" => $request->type,
"staging"=> $request->staging,
"domain" => $request->domain,
'status' => true,
"ip" => $request->ip,
"siteid"=> $request->siteid,
"isRenew" => $request->isRenew
]);
}else{
return redirect()->route('ping-domain-fail',[
"fname" => $request->fname,
"lname" => $request->lname,
"agentid" => $request->agenatid,
"auth" => $request->auth,
"email" => $request->email,
"prtname" => $request->prtname,
"cea"=> $request->cea,
"type" => $request->type,
"staging"=> $request->staging,
"domain" => $request->domain,
'status' => true,
"ip" => $request->ip,
"siteid"=> $request->siteid,
"isRenew" => $request->isRenew
]);
}
}else{
return redirect()->route('ping-domain-fail',[
"fname" => $request->fname,
"lname" => $request->lname,
"agentid" => $request->agenatid,
"auth" => $request->auth,
"email" => $request->email,
"prtname" => $request->prtname,
"cea"=> $request->cea,
"type" => $request->type,
"staging"=> $request->staging,
"domain" => $request->domain,
'status' => true,
"ip" => $request->ip,
"siteid"=> $request->siteid,
"isRenew" => $request->isRenew
]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire