PHP code example of digitonic / mdoc-api
1. Go to this page and download the library: Download digitonic/mdoc-api 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/ */
digitonic / mdoc-api example snippets
$baseUrl = 'https://mdoc.it/api/1.0/';
$apiKey = 'KxDMt9GNVgu6fJUOG0UjH3d4kjZPTxFiXd5RnPhUD8Qz1Q2esNVIFfqmrqgB';
// Instantiate a new Guzzle client
$guzzle = new \GuzzleHttp\Client([
'base_uri' => $baseUrl,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $apiKey
],
]);
// Instantiate a new mDoc API client with the Guzzle dependency.
$mdocApi = new \Digitonic\MdocApi\Client($guzzle)
$listTeams = new Digitonic\MdocApi\Teams\ListAllTeams($mdocApi);
$response = $listTeams->send();
print_r($response);
Collection {#548 ▼
#items: array:2 [▼
"data" => array:3 [▼
0 => {#597 ▼
+"uuid": "45bdd45e-59e4-11e9-a656-0a586460061d"
+"name": "Test Team 1"
+"owner": "87671060-4f20-11e9-8e5f-0a5864600621"
+"created_at": "2019-04-08 10:54:16"
+"updated_at": "2019-04-08 10:54:16"
}
1 => {#595 ▼
+"uuid": "cb886c4c-4f1d-11e9-b27f-0a5864600621"
+"name": "Test Team 2"
+"owner": "bea63aea-4f1d-11e9-a775-0a5864600621"
+"created_at": "2019-03-25 16:48:19"
+"updated_at": "2019-04-18 11:42:11"
}
2 => {#598 ▼
+"uuid": "77f98560-5b76-11e9-8a31-0a5864600906"
+"name": "Test Team 3"
+"owner": "19bca08a-5b72-11e9-a205-0a586460090b"
+"created_at": "2019-04-10 10:53:18"
+"updated_at": "2019-04-10 10:53:18"
}
]
"meta" => {#585 ▼
+"pagination": {#586 ▼
+"total": 3
+"count": 3
+"per_page": 15
+"current_page": 1
+"total_pages": 1
+"links": []
}
}
]
}
// config/app.php
'providers' => [
...
Digitonic\MdocApi\MdocApiServiceProvider::class,
...
];
// config/app.php
'aliases' => [
...
'ListAllTeams' => Digitonic\MdocApi\Facades\Teams\ListAllTeams::class,
'CampaignCreate'=> Digitonic\MdocApi\Facades\Campaigns\Create::class
...
];
return [
'base_url' => env('MDOC_BASE_URL', 'https://mdoc.it/api/1.0/'),
'api_key' => env('MDOC_API_KEY', ''),
];
// From a constructor
class FooClass {
public function __construct(Digitonic\MdocApi\Teams\ListAllTeams $listTeams) {
$listTeams->send();
}
}
// From a method
class BarClass {
public function barMethod(Digitonic\MdocApi\Teams\ListAllTeams $listTeams) {
$listTeams->send();
}
}
ListAllTeams:send();
bash
php artisan vendor:publish --provider="Digitonic\MdocApi\MdocApiServiceProvider"