Created
June 2, 2013 12:45
-
-
Save coderhs/5693543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* *** WHMCS JSON API Sample Code *** */ | |
$url = "localhost/order/includes/api.php"; # URL to WHMCS API file goes here | |
$username = "user"; # Admin username goes here | |
$password = "passs"; # Admin password goes here | |
$postfields = array(); | |
$postfields["username"] = $username; | |
$postfields["password"] = md5($password); | |
$postfields["action"] = "gettickets"; | |
$postfields["responsetype"] = "json"; | |
$postfields["limitstart"] = 3470; | |
$query_string = ""; | |
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 30); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
$jsondata = curl_exec($ch); | |
if (curl_error($ch)) die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); | |
curl_close($ch); | |
$arr = json_decode($jsondata); # Decode JSON String | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment