Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
https://yourdomain.com/installpath/index.php/api/users/get.json?user_id=1

...

To connect remotely, first determine the URL of the API for your installation. The default path is http://yourdomain.com/installpath/index.php/api/. Where yourdomain.com is the domain you've installed Blesta in, and installpath is the path to Blesta. If you have configured your installation to omit index.php from URLs then the URL should instead appear as http://yourdomain.com/installpath/api/.

...

Code Block
languagephp
titleConnecting Remotely
firstline1
linenumberstrue
<?php
// The URL to the API
$api_url = "https://yourdomain.com/installpath/index.php/api/";

// API credentials
$api_username = "username";
$api_key = "key";

// The Model to request
$model = "users";
// The method to request
$method = "get";
// The response format
$format = "json";

// All parameters to send
$params = array(
 'user_id'=>1
);


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url . $model . "/" . $method . "." . $format . "?" . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $api_username . ":" . $api_key);

$result = curl_exec($ch);
echo $result;
?>

...