Created
October 24, 2023 08:05
-
-
Save ochilab/620d909c6a01ffecf7454bf26cdf41cc to your computer and use it in GitHub Desktop.
GAS: Google Classroomの受講生のメールアドレスを取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUserEmailsInCourse(courseId) { | |
var emailList = []; | |
var nextPageToken; | |
do { | |
var response = Classroom.Courses.Students.list(courseId, { | |
pageToken: nextPageToken | |
}); | |
var students = response.students; | |
if (students && students.length > 0) { | |
for (var i = 0; i < students.length; i++) { | |
var userId = students[i].userId; | |
var email = students[i].profile.emailAddress; | |
emailList.push({ | |
userId: userId, | |
email: email | |
}); | |
} | |
} | |
nextPageToken = response.nextPageToken; | |
} while (nextPageToken); | |
return emailList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment