Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

PHP cPanel Authentication Check

Discussion in 'cPanel Developers' started by Gezor, May 15, 2011.

  1. Gezor

    Gezor Registered

    May 15, 2011
    Likes Received:
    Trophy Points:
    Hello Every Body,
    I need to know how i can write php script to check if the login is successful or not because i need to integrate cPanel API in my Script and i need this check ..

    Sorry for this bad English
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi Gezor,

    Currently there's not a direct way to check this. Each API query is authenticated at runtime using data sent in the HTTP headers. The way that I've seen other people perform a "check" of credentials is to make an API function call that produces a simple result set. If you receive the answer (any data), then the login username and password are correct; if you get "access denied" then your script would assume that the credentials are incorrect. An example function might be API2 StatsBar::stat. The information returned by that call can be minimal and is likely cached somewhere, so it an inexpensive call...the data returned doesn't even matter, just as long as you don't get "access denied".

    Since you want to use PHP, you should look at the PHP XML-API client class or the PHP PublicAPI client class. Those API client classes handle setting the authentication headers and properly structure you URL query for you. There are several example of the PHP XML-API client class in the forums. Both clients ship with example code.

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice