我是API上的新手,已經閱讀了JAVASCRIPT客戶端的文檔here,但我無法使事情工作,即使在身份驗證部分。我已經有PODIO本身的客戶端ID和ClientSecret。podio API JS瀏覽器身份驗證和API調用
基本上,我想使用客戶端(僅瀏覽器)以JSON格式獲取工作區中的所有podio數據。
我已經下載了庫here,並在我的本地主機上創建了一個HTML文件,並將podio-js與下面的代碼鏈接起來。獲取此錯誤「podio-js.js:1 Uncaught ReferenceError:require未在podio-js.js:1處定義」。我是否需要安裝一些東西,使裝載機的東西,使這項工作?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="lib/podio-js.js"></script>
<script type="text/javascript">
var podio = new PodioJS({
authType: 'server',
clientId: 'foo',
clientSecret: 'foo'
});
var redirectURL = 'http://localhost/PODIO-JS/podio-js-master/PODIO_CLIENT.html';
// Your request handler (for example in ExpressJS)
var action = function(request, response) {
var authCode = request.query.code;
var errorCode = request.query.error;
podio.isAuthenticated().then(function() {
// Ready to make API calls...
}).catch(function(err) {
if (typeof authCode !== 'undefined') {
podio.getAccessToken(authCode, redirectURL, function(err, response) {
// make API calls here
console.log (responsedata);
});
} else if (typeof errorCode !== 'undefined') {
// a problem occured
console.log(request.query.error_description);
} else {
// start authentication via link or redirect
console.log(podio.getAuthorizationURL(redirectURL));
}
});
</script>
</head>
<body>
</body>
</html>