-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiUser.php
More file actions
52 lines (37 loc) · 1.29 KB
/
apiUser.php
File metadata and controls
52 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
require 'vendor/autoload.php';
require __DIR__ . '/functions.php';
use function GuzzleHttp\json_encode;
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
//Test here
get_api_user();
function get_api_user()
{
$token = get_uuid();
$apiKey = $_ENV['API_KEY'];
$headers = [
'X-Reference-Id' => $token,
'Ocp-Apim-Subscription-Key' => $apiKey,
'Content-Type' => 'application/json'
];
$client = new GuzzleHttp\Client(['headers' => $headers]);
$body = '{
"providerCallbackHost": "https://webhook.site/37b4b85e-8c15-4fe5-9076-b7de3071b85d"
}';
try {
$response = $client->request('POST','https://sandbox.momodeveloper.mtn.com/v1_0/apiuser',
array("body" => $body));
print_r($response->getBody()->getContents());
} catch (\GuzzleHttp\Exception\RequestException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
}
?>