fork download
  1. <?php
  2. //Enter your endpoint
  3. $authorizationEndpoint = "https://s...content-available-to-author-only...y.com/api/v1/auth/login";
  4.  
  5. //Monnify API Credentials
  6. $clientID = "MK_TEST_1MC3T269JV";
  7. $clientSecret=
  8. "5PAV3G1Z4Q8JQ92G7XXD6K45CJ4YNMY6";
  9.  
  10.  
  11. //Set the request Header
  12. $headers = array(
  13. "Content-Type: application/json",
  14. "Authorization: Basic ". base64_encode($clientID . ":" . $clientSecret)
  15. );
  16.  
  17.  
  18. //Init the cURL session
  19. $ch = curl_init($authorizationEndpoint);
  20.  
  21. //Set some configurations
  22. curl_setopt($ch, CURLOPT_POST, 1);
  23.  
  24. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  25.  
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  27.  
  28. //Execute the cURL Session
  29. $response = curl_exec($ch);
  30.  
  31.  
  32. $responseData = json_decode($response);
  33.  
  34. echo "Access Token: " . $accessToken =$responseData->responseBody->accessToken;
  35. ?>
Success #stdin #stdout #stderr 0.03s 26296KB
stdin
 <?php
//Enter your endpoint
 $authorizationEndpoint = "https://s...content-available-to-author-only...y.com/api/v1/auth/login";

 //Monnify API Credentials
$clientID = "MK_TEST_1MC3T269JV";
$clientSecret=
"5PAV3G1Z4Q8JQ92G7XXD6K45CJ4YNMY6";
 

//Set the request Header
$headers = array(
 "Content-Type: application/json",
"Authorization: Basic ". base64_encode($clientID . ":" . $clientSecret)
);


 //Init the cURL session
$ch = curl_init($authorizationEndpoint);
 
//Set some configurations
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//Execute the cURL Session
$response = curl_exec($ch);


$responseData = json_decode($response);

 echo "Access Token: " . $accessToken =$responseData->responseBody->accessToken;
 ?>
stdout
 Access Token: 
stderr
PHP Notice:  Trying to get property 'responseBody' of non-object in /home/j5qaSn/prog.php on line 34
PHP Notice:  Trying to get property 'accessToken' of non-object in /home/j5qaSn/prog.php on line 34