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.

PHP cPanel Authentication Check

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

  1. Gezor

    Gezor Registered

    Joined:
    May 15, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    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.

    Regards,
    -DavidN
     
Loading...

Share This Page