Jump to content

Api call get password not working


silverspring

Recommended Posts

Hi,

 

i have 3 active whmcs website and i am developing a package to handle some of our needs.

 

I was trying to get users password with http://docs.whmcs.com/API:Get_Clients_Password But it seems not working;

 

I tried for my first website and it is returns wrongs users password.Checked so many times.

 

I tried for last 2 website and api cant find user at all.( Client ID Not Found )

 

I tried for both userid and password nothing has changed.I dont want to create custom api function.So any idea?

Link to comment
Share on other sites

Hi @klan

 

Here i am using external api, here is my code but i did try with rest clients like postman too.

 

WHMCS::getClientsPassword(12345)

<?php
 public function getClientsPassword($identity,$params=[])
   {
       is_int($identity) ? ($params['userid']=$identity) : ($params['email']=$identity);

       $response= $this->getJson('getclientpassword',$params);

       return !$response ?: $response->body->password;
   }

 

<?php
public function getJson($action,$params=NULL)
   {
       $data=[
           'action'=>$action,
           'responsetype'=>'json'
       ];

       $data = ($params===NULL) ?: array_merge($data,$params);

       $response = Request::get($this->dataUrl($data))
           ->expectsJson()
           ->send();

       if($response->body->result!='success')
       {
           return false;
       }

       return $response;
   }

$this->dataUrl simply generates url like

https://mywebsite.com/includes/api.php?username=<myusername>&password=<myMd5HashedPass>&action=getclientpassword&userid=12345

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated