这是我尝试过的所有代码都很好的代码,但是当它出现在这个函数之下时 ' function makeRequest(){'然后代码不执行并停止我认为响应此函数有问题
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
var CLIENT_ID = '988680082729- gudaete5nph93lq1sma15pb9cevi686r.apps.googleusercontent.com';
var API_KEY = 'AIzaSyDPC8gi0zrOFBQmxfgh7rXPU8EQDPe5w-Y';
var SCOPES = 'https://www.googleapis.com/auth/drive';
function handleClientLoad() {
gapi.client.setApiKey(API_KEY);
window.setTimeout(checkAuth,1);
}
function checkAuth() {
var options = {
client_id: CLIENT_ID,
scope: SCOPES,
immediate: true
};
gapi.auth.authorize(options, handleAuthResult);
}
function handleAuthResult(authResult) {
var authorizeButton = document.getElementById('authorize-button');
if (authResult && !authResult.error) {
authorizeButton.style.visibility = 'hidden';
makeApiCall();
} else {
authorizeButton.style.visibility = '';
authorizeButton.onclick = handleAuthClick;
}
}
function handleAuthClick(event) {
var options = {
client_id: CLIENT_ID,
scope: SCOPES,
immediate: false
};
gapi.auth.authorize(options, handleAuthResult);
return false;
}
function makeApiCall() {
gapi.client.load('drive', 'v2', makeRequest);
}
function makeRequest() {
var request = gapi.client.drive.files.list({'maxResults': 5 });
request.execute(function(resp) {
for (i=0; i<resp.items.length; i++) {
var titulo = resp.items[i].title;
var fechaUpd = resp.items[i].modifiedDate;
var userUpd = resp.items[i].lastModifyingUserName;
var userEmbed = resp.items[i].embedLink;
var userAltLink = resp.items[i].alternateLink;
var fileInfo = document.createElement('li');
fileInfo.appendChild(document.createTextNode('TITLE: ' + titulo + ' - LAST MODIF: ' + fechaUpd + ' - BY: ' + userUpd ));
document.getElementById('content').appendChild(fileInfo);
}
});
}
$(document).ready(function() {
$('#authorize-button').on('click', handleAuthClick);
$.getScript('//apis.google.com/js/api.js', function() {
gapi.load('auth:client', handleClientLoad);
});
});
</script>
</head>
<body>
<button id="authorize-button">Authorize</button>
<div id="content">Files:</div>
</body>
</html>
答案 0 :(得分:0)
我一直在找同样的东西找到这个https://developer.chrome.com/apps/angular_framework,它对我有用。
答案 1 :(得分:0)
您的请求将返回一个对象,该对象在我请求文件列表时,这些项目位于响应中的结果对象中。尝试在resp.result.items
函数中查找makeRequest()
。