Advertisement
Guest User

Whmcs API

a guest
Aug 12th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2. $whmcsUrl = "ApiURL";
  3. $username = "username";
  4. $password = "password";
  5.  
  6. $postfields = array(
  7.     'username' => $username,
  8.     'password' => md5($password),
  9.     'action' => 'GetClients',
  10.     'responsetype' => 'json',
  11. );
  12.  
  13. $ch = curl_init();
  14. curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
  15. curl_setopt($ch, CURLOPT_POST, 1);
  16. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
  21. $response = curl_exec($ch);
  22. if (curl_error($ch)) {
  23.     die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  24. }
  25. curl_close($ch);
  26.  
  27. $jsonData = json_decode($response, true);
  28.  
  29. var_dump($jsonData);
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement