2016-09-21 60 views
0

派生一個谷歌表單視圖ID當我定義表單,它的網址:自定義ID

https://docs.google.com/a/domain.com/forms/d/1d2Y9R9JJwymtjEbZI6xTMLtS9wB7GDMaopTQeNNNaD0/edit

我完成添加我想要的形式有,並使用「發送」的問題按鈕分發我的表單,我不單擊「在電子郵件中包含表單」複選框。我的個人電子郵件形式到現在臨危和電子郵件,邀請他們填寫表格,當他們這樣做,他們最終在頁面上具有以下網址:

https://docs.google.com/a/domain.com/forms/d/e/1FAIpQLScINR5rudwEKNVwlvz45ersqk_SO0kNcyN_EM1tJe3mXeFksw/viewform

在我的AppEngine/Python 2.7版代碼,我只能訪問這個ID - 「1d2Y9R9JJwymtjEbZI6xTMLtS9wB7GDMaopTQeNNNaD0」 - 我的問題是如何從這種原始的定義ID到視圖id得到 - 「1FAIpQLScINR5rudwEKNVwlvz45ersqk_SO0kNcyN_EM1tJe3mXeFksw」

我已經使用谷歌驅動v2和v3嘗試REST API來檢索'定義'文件,但響應沒有引用(我可以看到)這個'視圖'ID。 我也嘗試使用Google AppsScript FormApp API來檢索'定義'表單,但是這也沒有包含'view'id的引用(我可以看到)。 在所有我嘗試過的情況下,如果我使用「視圖」ID作爲源,則API返回404錯誤,指示此「視圖」ID不是Google Drive文件的ID。

任何想法?

回答

0

使用谷歌Apps腳本發佈Web應用程序(或使用執行API)來leaverage了 「getPublishedUrl」 功能

function doGet(theRequest){ 
    var theDefinitionId = theRequest.parameters.formId; 
    var thePublishedUrl = myAPI_(theDefinitionId); 
    var output = ContentService.createTextOutput(thePublishedUrl); 
    output = output.setMimeType(ContentService.MimeType.JSON); 
    return output; 
} 

function myAPI_(theDefinitionId){ 
    var thePublishedUrl = null; 
    try{ 
    var existingForm = FormApp.openById(theDefinitionId); 
    thePublishedUrl = existingForm.getPublishedUrl(); 
    } catch (err){ 
    Logger.log(err); 
    } 
    var theReturn = {publishedUrl: thePublishedUrl}; 
    var theJSONReturn = JSON.stringify(theReturn); 
    return theJSONReturn; 
}