lipa na mpesa daraja php

Solutions on MaxInterview for lipa na mpesa daraja php by the best coders in the world

showing results for - "lipa na mpesa daraja php"
Carlos
23 May 2017
1  <?php
2  $url = 'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials';
3  
4  $curl = curl_init();
5  curl_setopt($curl, CURLOPT_URL, $url);
6  $credentials = base64_encode('YOUR_APP_CONSUMER_KEY:YOUR_APP_CONSUMER_SECRET');
7  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$credentials)); //setting a custom header
8  curl_setopt($curl, CURLOPT_HEADER, true);
9  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
10  
11  $curl_response = curl_exec($curl);
12  
13  echo json_decode($curl_response);
14  
15  ?>
16