$VAR1 = { \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'param0' => 'cptest_dbname', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'param1' => 'cptest_', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'param2' => 'ALTER CREATEROUTINE TEMPORARY CREATE DELETE DROP SELECT INSERT UPDATE REFERENCES INDEX LOCK ' \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0}; \n<\/code><\/p>\nThese indicate the order of parameters to API1, starting with param0 to paramn<\/em>. \u00a0This data can be correlated to what input was given to the cPanel interface to determine the call.<\/p>\nWith API2, since it uses named parameters, rather than ordered parameters you will see something like the following: \n$cfgref \n$VAR1 = { \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'quota' => 250, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'password' => 'somepasswprd', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'domain' => 'somedomain.com', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0'email' => 'someuser' \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0}; \n<\/code><\/p>\nWith these, the parameter name maps directly to the parameter name for API2. \u00a0This is fairly easy to understand, however there are a few things that need to be noted. \u00a0Firstly, use of generic parameters that will probably not aid you. \u00a0There are a few of these mostly prefixed with \u201capi2_\u201d, are used for things like sorting, pagination, searching, etc. \u00a0The other main parameter to pay attention to is \u201ccache_fix\u201d which is used for browser caching and should always be ignored.<\/p>\n
Understanding the output from $dataref<\/strong> \nOne thing that you will only see in \u201cpost\u201d calls, is the $dataref being populated. \u00a0This contains the output from the Tracer. API1 output is usually straight forward, as they return strings rather than data structures. Take for example, Email::addpop, it will return the name of the email address: \nemail+domain.com<\/em><\/p>\nThis will be populated with an error message in the case of an error.<\/p>\n
API2, as it\u2019s far more robust than API1, returns actual data structures. \u00a0These can be complex to work with. \u00a0Please refer to the API2 documentation (link) on how to work with this data. \u00a0When it is returned it will look like the following: \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0{ \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'diskquota' => 250, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'humandiskquota' => '250 MB', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'user' => 'asdge33', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'_diskused' => 0, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'humandiskused' => 'None', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'_diskquota' => 262144000, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'txtdiskquota' => 250, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'diskusedpercent' => 0, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'diskusedpercent20' => 0, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'login' => 'asdge33@cptest.com', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'domain' => 'cptest.com', \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'diskused' => 0, \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0'email' => 'asdge33@cptest.com' \n\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0}, \n<\/code><\/p>\nThis would be displayed in XML format via the XML-API by: \n\u2212 \n<data> \n<_diskquota>262144000<\/_diskquota> \n<_diskused>0<\/_diskused> \n<diskquota>250<\/diskquota> \n<diskused>0<\/diskused> \n<diskusedpercent>0<\/diskusedpercent> \n<diskusedpercent20>0<\/diskusedpercent20> \n<domain>cptest.com<\/domain> \n<email>asdge33@cptest.com<\/email> \n<humandiskquota>250 MB<\/humandiskquota> \n<humandiskused>None<\/humandiskused> \n<login>asdge33@cptest.com<\/login> \n<txtdiskquota>250<\/txtdiskquota> \n<user>asdge33<\/user> \n<\/data> \n<\/code><\/p>\nThere are some shortcomings that need to be noted:<\/p>\n
\nThis version of Tracer requires that \/dev\/shm to be writable, the path for the temp file can be edited within the script however \/dev\/shm is the fastest place.<\/li>\n This means that usernames and passwords for anything created\/modified through the cPanel interface will be written to the error_log. \u00a0You need to clear the error_log after enabling this, and be careful that it\u2019s not left running on a production server due to the inherent security risks.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"At this point, cPanel\u2019s APIs are not 100% documented. \u00a0We are working on it and hope to have complete API docs up in a few months. \u00a0I\u2019ve written a CustomEventHandler\u00a0that will print every API call made into cpanel\u2019s error_log (\/usr\/local\/cpanel\/logs\/error_log). Installation To use the API Tracer, you will need to download it, then place the […]<\/p>\n","protected":false},"author":77,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-63169","post","type-post","status-publish","format-standard","hentry","category-products"],"acf":[],"yoast_head":"\n
How to trace the cPanel API | cPanel<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n