Advertisement
Guest User

Untitled

a guest
Nov 21st, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2. /**
  3.  * WHMCS Sample API Call
  4.  *
  5.  * @package    WHMCS
  6.  * @author     WHMCS Limited <development@whmcs.com>
  7.  * @copyright  Copyright (c) WHMCS Limited 2005-2016
  8.  * @license    http://www.whmcs.com/license/ WHMCS Eula
  9.  * @version    $Id$
  10.  * @link       http://www.whmcs.com/
  11.  */
  12.  
  13. // The fully qualified URL to your WHMCS installation root directory
  14. $whmcsUrl = "https://portal.goosevpn.com/";
  15.  
  16. // Admin username and password
  17. $username = "reaper";
  18. $password = "82ifyc82";
  19.  
  20. // Set post values
  21. $postfields = array(
  22.     'username' => $username,
  23.     'password' => md5($password),
  24.     'action' => 'validatelogin',
  25.     'email' => 'misha.vavryniuk@gmail.com',
  26.     'password2' => urlencode('hN&jr4g_tmk#?c3'),
  27.     'responsetype' => 'json',
  28. );
  29.  
  30. // Call the API
  31. $ch = curl_init();
  32. curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
  33. curl_setopt($ch, CURLOPT_POST, 1);
  34. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
  37. $response = curl_exec($ch);
  38. if (curl_error($ch)) {
  39.     die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  40. }
  41. curl_close($ch);
  42.  
  43. // Attempt to decode response as json
  44. $jsonData = json_decode($response, true);
  45.  
  46. // Dump array structure for inspection
  47. var_dump($jsonData);
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement