Standardized hook - Retrieve PostURL

Haioken

Member
Feb 27, 2017
7
0
1
Australia
cPanel Access Level
Root Administrator
Hi All,

I have a need to trigger post events to the iContact PostURL (WHM -> Basic WebHost Manager Setup -> Contact Information -> URLs of a system to which you want to send POST notifications) via a standardized hook.
As the contact manager does not have this capability, I've written a standardized hook to perform the curl request.

At the moment, I'm retrieving this from /etc/wwwacct.conf.shadow (CONTACTPOSTURL https://dev-api.<redacted>/postMsg).

Is this the correct place on the filesystem to retrieve this?
Is there a better way of doing this? How? (IE: A cpanel module I can include to retrieve this)

Kind Regards,

Hayden Katz
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,862
2,216
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @Haioken,

The following WHM API 1 function may help:

WHM API 1 Functions - verify_posturl_access - Developer Documentation - cPanel Documentation

Per it's description:

This function calls the WHM API 1 send_test_posturl function for your specified POST notification URLs. You can specify POST notification URLs in the Contact Information section of WHM's Basic WebHost Manager Setup interface ( WHM >> Home >> Server Configuration >> Basic WebHost Manager Setup) .
Let me know if this is what you are looking for.

Thank you.
 

Haioken

Member
Feb 27, 2017
7
0
1
Australia
cPanel Access Level
Root Administrator
Hi @cPanelMichael,

Unfortunately, this isn't what I'm looking for. This function only tells me that the postURL is valid and responds OK.
I need to retrieve the PostURL from inside a standardized hook that I've attached to various functions (Such as Api2::SubDomain::addsubdomain) so that I send a post to it from within the standardized hook.

The idea is to send cPanel contact manager like post to url events for functions that are not supported by contact manager (Such as creation of sub/parked/addon domains, autossl notifications)

Is there a recommended way of retrieving the PostURL as stored in [ WHM -> Basic WebHost Manager® Setup -> Contact Information -> A comma-separated list of http:// or https:// URLs ... ] ?
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,862
2,216
363
cPanel Access Level
DataCenter Provider
Twitter
Is there a recommended way of retrieving the PostURL as stored in [ WHM -> Basic WebHost Manager® Setup -> Contact Information -> A comma-separated list of http:// or https:// URLs ... ] ?
Hello @Haioken :)

I don't see a specific WHM API 1 function that will output the server's configured PostURL value. However, you should be able to review the contents of the following Perl module to get an idea of how you'd obtain this information in a script:

/usr/local/cpanel/Cpanel/iContact/Provider/Schema/Posturl.pm

Here's an additional document that may point you in the right direction:


Let me know if this helps.

Thank you.
 

Haioken

Member
Feb 27, 2017
7
0
1
Australia
cPanel Access Level
Root Administrator
Thanks for looking into it @cPanelMichael.

Both of those rely on being passed information from the iContact module
- Posturl.pm receives the URLs provided as a CSV parameter to`sub get_settings`
- The documentation provided refers to extending PostURL

Unfortunately, I need access to this information from a Standardized Hook, not from within the iContact system.
This is because I'm attempting to send notifications to a service for events that are not handled by iContact - Thus I am hooking the appropriate UAPI/API2 calls as necessary.

I've built my hook script using direct interpretation of the /etc/wwwacct.conf.shadow file.
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,862
2,216
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @Haioken,

Consider uploading an example of your hook script to a GitHub repo and sharing the link here if you have the time. This is more likely to inspire others to share suggestions or submit changes.

Thanks!