1. Go to this page and download the library: Download bluerocktel/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bluerocktel / php-sdk example snippets
use BlueRockTEL\SDK\BlueRockTELConnector;
$api = new BlueRockTELConnector(
'https://telecomxxxx-admin.bluerocktel.net/api/',
'[email protected]',
'secret',
);
$response = $api->helper()->version();
var_dump(
$response->failed(), // true is the request returned 4xx or 5xx code.
$response->json(), // json response as an array
);
use BlueRockTEL\SDK\BlueRockTELConnector;
use BlueRockTEL\SDK\Endpoints;
$api = new BlueRockTELConnector(BLUEROCKTEL_API_URL, BLUEROCKTEL_API_USERNAME, BLUEROCKTEL_API_PASSWORD);
$response = $api->call(
new Endpoints\GetVersionRequest()
);
$response = $api->call(
new Endpoints\Prospects\GetProspectRequest(id: $prospectId)
);
class NamespaceResource
{
public function index(array $params = [], int $perPage = 20, int $page = 1): Response;
public function show(int $id): Response;
public function store(Entity $entity): Response;
public function update(Entity $entity): Response;
public function upsert(Entity $entity): Response;
public function delete(int $id): Response;
}
use BlueRockTEL\SDK\BlueRockTELConnector;
use BlueRockTEL\SDK\Resources\ProspectResource;
$api = new BlueRockTELConnector();
$resource = new ProspectResource($api);
$prospect = $resource->show($prospectId);
$resource->upsert($prospect);
// Check response status
$response->ok();
$response->failed();
$response->status();
$response->headers();
// Get response data
$response->json(); # as an array
$response->body(); # as an raw string
$response->dtoOrFail(); # as a Data Transfer Object
$query = [
'sort' => 'created_at',
];
# Create a PagedPaginator instance
$paginator = $api->paginate(new GetProspectsRequest($query));
# Iterate on all pages entities, using lazy loading for performance
foreach ($paginator->items() as $prospect) {
$name = $prospect->name;
$customerAccount = $prospect->customerAccount;
}
use BlueRockTEL\SDK\BlueRockTELConnector;
class MyCustomConnector extends BlueRockTELConnector
{
public function defaultConfig(): array
{
return [
'timeout' => 120,
];
}
public function customResource(): \App\Resources\CustomResource
{
return new \App\Resources\CustomResource($this);
}
}
$api = new MyCustomConnector(BLUEROCKTEL_API_URL, BLUEROCKTEL_API_USERNAME, BLUEROCKTEL_API_PASSWORD);
$api->customResource()->index();
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.