PHP code example of dapi-co / dapi-php

1. Go to this page and download the library: Download dapi-co/dapi-php 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/ */

    

dapi-co / dapi-php example snippets


// Assuming that Dapi library is already autoloaded. If not, manually include/
 
$accessToken = 'ACCESS_TOKEN'; 
$userSecret = 'USER_SECRET'; 
$accounts = $dapiClient->data->getAccounts($accessToken, $userSecret);
echo PHP_EOL . 'Accounts' . PHP_EOL . PHP_EOL;
echo (json_encode($accounts, JSON_PRETTY_PRINT));



// Assuming that Dapi library is already autoloaded. If not, manually include/harset=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");

// Initialize DapiClient with your appSecret here
$dapiClient = new Dapi\DapiClient('APP_SECRET');

$headers = getallheaders();
$body = json_decode(file_get_contents("php://input"), true);

// Make dapiClient automatically handle your SDK requests
if (!empty($body)) {
  echo json_encode($dapiClient->handleSDKRequests($body, $headers)); 
} else {
  http_response_code(400);
  echo "Bad Request: No data sent or wrong request";
}

function exchangeToken($accessCode, $connectionID)

function getIdentity($accessToken, $userSecret, $userInputs = [], $operationID = "")

function getAccounts($accessToken, $userSecret, $userInputs = [], $operationID = "")

function getBalance($accessToken, $userSecret, $accountID, $userInputs = [], $operationID = "")

function getTransactions($accessToken, $userSecret, $accountID, $fromDate, $toDate, $userInputs = [], $operationID = "")

function getBeneficiaries($accessToken, $userSecret, $userInputs = [], $operationID = "")

function createTransfer($accessToken, $userSecret, $transferData, $userInputs = [], $operationID = "")

function transferAutoflow($accessToken, $userSecret, $transferAutoFlowData, $userInputs = [], $operationID = "")
bash
composer 
go
function createBeneficiary($accessToken, $userSecret, $beneficiaryData, $userInputs = [], $operationID = "")