0

リアルタイムdocに関するユーザーの役割を取得し、doc.getCollaborators()で協力者を得て、これは私にdocがタイプgapi.drive.realtime.Documentからである配列[]与えます:GoogleのリアルタイムAPI /ドライブAPIは - >私はリアルタイムのアプリを持っている

enter image description here

API Referenceによると、現在の協力者がリアルタイムドキュメントの所有者であるなら、私を示しisOwnerようにはフィールド「doc

私の質問どのように私はその役割コラボを見つけることができますがありませんオレーターのdocがあります。私が見つけAPIドキュメントで :「リアルタイムAPIは、所有者、リーダライタの役割をサポートしています」

私はgapi.client.drive.permissions.listを使用しようとするとgoogle drive api referenceからの提案:

function retrievePermissions(fileId, callback) { 
     var request = gapi.client.drive.permissions.list({ 
      'fileId': fileId 
     }); 
     request.execute(function (resp) { 
      callback(resp.items); 
     }); 
    } 


    retrievePermissions(self.realtimeDocId, function (resp) { 
     resp; 


     }); 

それから私は、次のエラーメッセージが表示されます。

Error in Realtime load callback: TypeError: Cannot read property 'permissions' of undefined TypeError: Cannot read property 'permissions' of undefined

答えて

0

ドライブAPIを使用するには、Realtime APIとは別にロードする必要があります。

window.gapi.client.load('drive', 'v3', function() 
{ 
    // Run your code here. 
}); 

許可リストを取得したら、RealtimeDoc :: getCollaborators呼び出しから返された各ユーザーのアクセス許可IDを使用できます。

0

コードの配置方法を確認したい場合は、documentationに基づいて、Realtime APIをドライブプラットフォームに統合することができます。コードの実装については

Realtime documents are attached to files stored in Google Drive. Accordingly, your application should use the Drive REST API to interact with Drive files. For example, to create a new file, use the files.insert method from the Drive REST API. To retrieve a file that already exists, use the files.get method.

For more information on interacting with files in Google Drive, see Google Drive Integration .

あなたはCodeMirror Collaboration with Google Drive Realtime Apiを確認することができます。

ドライブのAPI:リアルタイムAPIについては

/** 
* Creates a new Realtime file. 
* @param title {string} title of the newly created file. 
* @param callback {Function} the callback to call after creation. 
*/ 
rtclient.createRealtimeFile = function(title, callback) { 
    gapi.client.load('drive', 'v2', function() { 
    gapi.client.drive.files.insert({ 
     'resource': { 
     mimeType: rtclient.REALTIME_MIMETYPE, 
     title: title 
     } 
    }).execute(callback); 
    }); 
} 

:この情報が役立ちます

// We have a file ID in the query parameters, so we will use it to load a file. 
    if (fileId) { 
    gapi.drive.realtime.load(fileId, this.onFileLoaded, this.initializeModel, handleErrors); 
    return; 
    } 

希望。

関連する問題