manoaratefy

Well-Known Member
Nov 17, 2018
49
4
8
Madagascar
cPanel Access Level
Root Administrator
Good morning,

How to use WHM API inside WHM plugin? I see the LiveAPI System but it seems only for cPanel API, not WHM API.

Note that my plugin is written in PHP. I already looked on documentation but nothing releveant.

Thanks in advance.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
5,465
698
313
cPanel Access Level
Root Administrator
Hey there! As you've found, the WHM integrations are very limited, so there likely are not any PHP examples out there.

I have an older example I wrote several years ago with Perl that shows how you can add a token to verify your call:


but I'm not sure how much of that would apply to a PHP environment.
 

manoaratefy

Well-Known Member
Nov 17, 2018
49
4
8
Madagascar
cPanel Access Level
Root Administrator
Hello,

Thank you. Your documentation talk about using access hash but as far as I know, access hash is deprecated. Another method is to use API token but I think it's not a good idea to create an API token per WHM user, and I'm risking to break my module if someone delete its API token.

Is there any way to log in into WHM API other than these two methods?
 

manoaratefy

Well-Known Member
Nov 17, 2018
49
4
8
Madagascar
cPanel Access Level
Root Administrator
Hello,

Finally, I went by running whmapi1 binary using shell_exec PHP function to call WHM and cPanel API. Also, I've found that running whmapi1 provide me better performance than calling the API throught cURL on "127.0.0.1" (0.01 sec difference).
 
  • Like
Reactions: cPRex