Skip to main content

Create database using PHP API

Comments

2 comments

  • cPanelMichael
    Hello @jason213, The following user-submitted example should offer some insight on how to do this:
    0
  • jason213
    Hello, thank for you reply. for other persons that are looking for the same solution, i have found the code below that work for me. I don"t understand why cpanel is too much complicated to request a simple database, i hope in the future cpanel don"t change code again, because the suport from their side simple don"t exist and cpanel is not a cheap solution. We developers don"t have time to deal with changes like this without decent suport, this is my opinion, i use others panel solutions for years and i don"t have this problem in other solutions next time i have a problem i will think about to change control painel provider. Thanks, Bruno $server_login_link = 'url'; $whmusername = 'user'; $hash = 'token'; $query = "https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=MysqlFE&cpanel_jsonapi_func=createdb&db=example_database"; $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); $header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash); curl_setopt($curl,CURLOPT_HTTPHEADER,$header); curl_setopt($curl, CURLOPT_URL, $query); $result = curl_exec($curl); print_r(json_decode($result));
    0

Please sign in to leave a comment.