[英]Integrating Plaid and Google Apps Script
bkper.com 的聯合創始人在這里。
我們使用 Plaid 為用戶提供直接的銀行連接,提供Google Apps 腳本庫以在安全的 OAuth2 層下輕松訪問數據。
您可以使用它來訪問您的數據,而無需擔心實現鏈接連接和令牌管理:-)
前 Plaid 員工在這里。 下面是獲取項目第一個帳戶余額的示例。 在此示例中每 12 小時檢索一次,但可以刪除該邏輯。
function getBalance() {
var cache = CacheService.getScriptCache();
var lastUpdated = cache.get('lastUpdated');
// update every 12 hours
if (lastUpdated == null || Date.now() - Date.parse(lastUpdated) > 1000 * 60 * 60 * 12) {
var payload = {
"client_id": "your_client_id",
"secret": "your_secret",
"access_token": "relevant_access_token",
"options": {
"account_ids": ["account_id1", "account_id2"]
}
};
var res = UrlFetchApp.fetch("https://production.plaid.com/accounts/balance/get", {'method': 'post', 'contentType': 'application/json', 'payload': JSON.stringify(payload)});
var obj = JSON.parse(res.getContentText());
var ret = obj.accounts[0].balances.available;
cache.put('lastBalance', String(ret));
cache.put('lastUpdated', new Date().toISOString());
return ret;
}
return Number(cache.get('lastBalance'));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.