...
Note |
---|
title | Running PHP in CGI or FCGId mode? |
---|
|
Update your .htaccess file to pass an environment variable to Blesta so it can capture the basic authentication details as per the following snippet: Code Block |
---|
| RewriteEngine on
...
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
...
Section |
---|
Column |
---|
|
Code Block |
---|
language | php |
---|
firstline | 1 |
---|
title | Connecting Remotely with PHP |
---|
firstline | 1 |
---|
linenumbers | true |
---|
| <?php
require_once "blesta_api.php";
$user = "username";
$key = "key";
$url = "https://yourdomain.com/installpath/api/";
$api = new BlestaApi($url, $user, $key);
$response = $api->get("users", "get", array('user_id' => 1));
print_r($response->response());
print_r($response->errors());
?> |
|
Column |
---|
|
Code Block |
---|
language | bash |
---|
title | Connecting Remotely with cURL |
---|
| curl https://yourdomain.com/installpath/api/users/get.json?user_id=1 -u username:key |
|
|
...
If you're working with or have created code within the Blesta environment, there's no need to use the API at all. All of the methods available in the API are first and foremost available to Blesta, in the form of models. To use these models, simply load the model within your environment.
Code Block |
---|
language | php |
---|
firstline | 32 |
---|
title | Loading Models from a Controller | firstline |
---|
32 | linenumbers | true |
---|
|
// from somewhere in your controller...
$this->uses(array("ModelName"));
// Now invoke it
$this->ModelName->someMethod($param1, $param2); |
Code Block |
---|
language | php |
---|
firstline | 54 |
---|
title | Loading Models elsewhere | firstline | 54 |
---|
linenumbers | true |
---|
|
// from any other class...
Loader::loadModels($this, array("ModelName"));
// Now invoke it
$this->ModelName->someMethod($param1, $param2); |
...