【发布时间】:2012-12-12 07:54:32
【问题描述】:
我正在尝试将图像文件上传到谷歌驱动器... 代码;
function upload() {
var url= // url for image
var contents=UrlFetchApp.fetch(url).getContent() // trying to get image content
var base = 'https://docs.google.com/feeds'
var fetchArgs = googleOAuth_('docs', base);
fetchArgs.method='POST'
fetchArgs.contentType='image/jpeg'
var xml={title :"image",content:contents}
fetchArgs.payload=xml
var fileURL='https://www.googleapis.com/upload/drive/v2/files?uploadType=media'
UrlFetchApp.fetch(fileURL, fetchArgs)
}
function googleOAuth_(name,scope) {
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey(consumerKey);
oAuthConfig.setConsumerSecret(consumerSecret);
return {oAuthServiceName:name, oAuthUseToken:"always"};
}
当我运行这段代码时,我收到了这个错误:
返回代码 403 的请求失败。服务器响应:{“error”:{“errors”:[{“domain”:“usageLimits”,“reason”:“dailyLimitExceededUnreg”,“message”:“未验证的每日限制使用已超过。继续使用需要注册。", "extendedHelp": "https://code.google.com/apis/console" } ], "code": 403, "message": "每日未验证使用限制已超过。继续使用需要注册。" } }
我做错了什么,我没有得到这个......请给我一些可行的解决方案
【问题讨论】:
标签: google-apps-script google-drive-api