The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Prerequisites for user script access to API1

Discussion in 'cPanel Developers' started by SAbboushi, Oct 25, 2012.

  1. SAbboushi

    SAbboushi Registered

    Joined:
    Oct 25, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    I have been browsing the forum for a couple of hours now and done some (failed) testing with xmlapi.php...

    Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for /https://boxxxx.bluehost.com:2087/json-api/cpanel?cpanel_jsonapi_user=soush&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=addpop&cpanel_jsonapi_apiversion=1&arg-0=somerandomuser&arg-1=adfm90f1m3f0m0adf&arg-2=10&arg-3=w3x4.com in D:\Documents\www\cpanel\xmlapi.php on line 730

    It is still unclear to me whether any user who has a cpanel account is able to write their own php scripts and utilize API1 and API2...

    Can someone please confirm for me the requirements if any, e.g.

    1) seems older versions of cpanel don't support this

    2) is any type of authentication other than cpanel username/password required (I saw a post suggesting domain root privileges might be needed; and DavidN suggesting SSL is relevant)

    3) can resellers/admins prevent such access by disabling ports or some other methods?

    Thanks--
    Sam
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    if you're making an API1 or API2 call and authenticating as a reseller (who owns the cPanel user being affected or authenticating as root), then you should use port 2087 (SSL) or 2086 (non-SSL). If you're authenticating as the actual cPanel user that is affected by the call the you should use port 2083 (SSL) or 2082 (non-SSL).

    The error you mention is not from the cPanel server, but from your script. It's possible, but I would think improbable, that your hosting provider has setup some counter measure to block access. If you log into WHM on that same protocol/IP address/port in your browser, you should be able to paste the xmlapi.php generated url in your browser, click 'go', and have a success (the authentication will be session based and managed by the browser [you might need to add cpsession token to the url, if your server implements that for browser sessions]; when the xmlapi.php sends request, it passes authentication information in the HTTP header...there's no cpsession token required since the authentication and action are in one request).

    so:
    1) cPanel 11.25+ will support the XML/JSON remote API and can proxy the API1 and API2 calls (IIRC, it works as far back as 11.23, but I know for certain it works on 11.25+)

    2) No, see my note above. You can use a root access hash if you like, however A) you need to be root to have access to that hash key in the first place and B) it's just another authentication type, it's not a requirement, you'd use it in leu of a password for a root authenticated request; I don't think it will solve your issue.

    3) It's impractical to block access for the remote API since it's used within cPanel/WHM itself. Like I said earlier, it possible, but highly unlikely that some (admin/root/hosting company) has put such blockers in place. Such blocks are not supported by cPanel/WHM

    Regards,
    -DavidN
     
  3. SAbboushi

    SAbboushi Registered

    Joined:
    Oct 25, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    DavidN - thank you very much for taking the time to answer my questions. It will take me awhile to try to understand everything you've written -- but I appreciate you pointing me in the right direction.
     
Loading...

Share This Page