<?php
    function access_token() {
        $request = new Http_Request2('https://proxy.momoapi.mtn.com/collection/token/');
        $url = $request->getUrl();
        
        $apiuser    =   '076b7270-a3ba-4800-9bb7-2ef9776e369f';
        $apikey     =   'dee3405887d64a98b9455e7ed46374e3';
        $token      =    base64_encode($apiuser.':'.$apikey);

        $headers = array(
            // Request headers
            'Authorization' => 'Basic '.$token,
            'Ocp-Apim-Subscription-Key' => 'b4cfab4d10ac4416921694591c061a76',
        );
        
        $request->setHeader($headers);
        
        $parameters = array(
        );
        
        $url->setQueryVariables($parameters);
        
        $request->setMethod(HTTP_Request2::METHOD_POST);
        
        // Request body
        $request->setBody("");
        $accesstoken = '';
        try {
            $response = $request->send();
            $access_token = json_decode($response->getBody());
            $accesstoken = $access_token->access_token;
        } catch (HttpException $ex) {
            echo $ex;
        }
        return $accesstoken;
    }
    function access_tokenD() {
        $request = new Http_Request2('https://proxy.momoapi.mtn.com/disbursement/token/');
        $url = $request->getUrl();
        
        $apiuser    =   '83a13ee1-f2b5-42bc-ade3-c53d43a1975b';
        $apikey     =   '3f165f618ecb436eaec2536022a8c4f7';
        $token      =    base64_encode($apiuser.':'.$apikey);

        $headers = array(
            // Request headers
            'Authorization' => 'Basic '.$token,
            'Ocp-Apim-Subscription-Key' => 'b97a594500bc41a5b23315af0d52d06b',
        );
        
        $request->setHeader($headers);
        
        $parameters = array(
        );
        
        $url->setQueryVariables($parameters);
        
        $request->setMethod(HTTP_Request2::METHOD_POST);
        
        // Request body
        $request->setBody("");
        $accesstoken = '';
        try {
            $response = $request->send();
            $access_token = json_decode($response->getBody());
            $accesstoken = $access_token->access_token;
        } catch (HttpException $ex) {
            echo $ex;
        }
        return $accesstoken;
    }
?>    