get main domain using php api2
Hey everyone,
Ive used the method provided in the API2 docs to get the main domain the script is running through. I dont get any errors but nothing is returned when i use the api. This is what i have.
[PHP]
$base_domain = $GLOBALS['cpanel">->api2(
'DomainLookup', 'getmaindomain'
);
[/PHP]
And this is how I'm trying to get the domain from the json output:
[PHP]
$url_array = json_decode($base_domain, true);
$url = $url_array['cpanelresult">['data">[0]['main_domain">;
[/PHP]
Can some please tell me the problem with my code.
Regards
-
Hello :) Are you able to view the proper output when using "WHM Home >> Development >> API Shell"? Note that this function is documented here: cPanel API 2 Functions - DomainLookup::getmaindomain Thank you. 0 -
Hey Michael, Got it to work... Apparently I don't have to json_decode the output from the api. I thought a json object is returned so I had to decode it. Thats what the api says.. Anyways thanks for the help though. Regards. 0 -
I am happy to see you were able to resolve the issue. Thank you for updating us with the outcome. 0
Please sign in to leave a comment.
Comments
3 comments