0
{"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}

like this i will get json for every api call from all the calls i have to get the reason and store it in database

NOTE:In the code api call made with header() to connect WHM.i cann't able to use that api as url and decode it

thank you in advance

Eddie
  • 26,593
  • 6
  • 36
  • 58
Linga
  • 1
  • I'm sorry. but I'm familiar with PHP and WHM, and still I cant seem to understand your question at all. – JohnnyJS May 25 '18 at 14:47
  • i have given cpanel create account api in php header("json-api"),once the header executed it gives u the json result including username,password, ip etc...now from php i need to get those username and password details.how can i get that – Linga May 25 '18 at 15:00
  • if ( isset( $_POST["submitButton"] ) ) { $url = header( "Location: https://hostname.com:2087/cpsess######/json-api/createacct?api.version=1&username={$user_name}&domain={$domain_name}&plan=Basic&featurelist=default&quota=0&password={$user_pass}&ip=n&cgi=1&hasshell=1&%20&cpmod=paper_lantern&maxftp=5&maxsql=5&maxpop=10&maxlst=5&maxsub=1&maxpark=1&maxaddon=1&bwlimit=500&language=en&useregns=1&hasuseregns=1&reseller=0&forcedns=0&%20mxcheck=local%20&max_defer_fail_percentage=80&owner=root"); $data = json_decode($url) echo $data->metadata;exit;------------this is the code – Linga May 25 '18 at 15:04
  • Please have a look at the [documentation](https://documentation.cpanel.net/display/DD/Guide+to+cPanel+API+2). It might help you a lot. – JohnnyJS May 25 '18 at 15:05
  • If you are trying to redirect user to account creation page, you will use `header('Location: ...');`. and right after `exit();`. the json-api is designed to deliver JSON data to AJAX calls. and ultimately, you have to do this at client side, and not in PHP. – JohnnyJS May 25 '18 at 15:10

0 Answers0