我有一个文件夹,我想在其中插入一个文件....文件是一个图像,我在 photoURL 变量中提供了它的 url 我的代码:
var consumerKey="yourDomain.com";
var consumerSecret="yourSecretKey";
function image() {
// Photo url
var photoURL="photourl"
// Getting content of Image
var imageContent=UrlFetchApp.fetch(photoURL).getContent()
// Storing image into drive
storeIntoDrive(imageContent)
}
// Oauth Authentication
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"};
}
// To store image into Google Drive
function storeIntoDrive(content){
var base="https://www.googleapis.com/auth/drive.file"
var url='https://www.googleapis.com/upload/drive/v2/files?uploadType=media'
var fetchArgs=googleOAuth_('drives',base)
fetchArgs.payload=content
fetchArgs.method='POSt'
fetchArgs.contentType="images/jpeg"
fetchArgs.header={"title" : "demo", "mimeType" : "image/jpeg",
"parents": [{
"kind": "drive#fileLink",
"id": "0B3qF7GcD2uDHc2J5d21haFJFc0k"
}]}
var result=UrlFetchApp.fetch(url,fetchArgs)
}
它没有插入图像....我应该做些什么改变????
它给出了错误:
返回代码 403 的请求失败。服务器响应:{“错误”:{“错误”:[{“域”:“usageLimits”,“原因”:“dailyLimitExceededUnreg”,“消息”:“未验证使用的每日限制已超过。继续使用需要注册。", "extendedHelp": " https://code.google.com/apis/console " } ], "code": 403, "message": "已超过每日未经验证使用的限制。继续使用需要报名。” } }