Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 获取用户';谷歌脚本中的个人资料信息_Google Apps Script - Fatal编程技术网

Google apps script 获取用户';谷歌脚本中的个人资料信息

Google apps script 获取用户';谷歌脚本中的个人资料信息,google-apps-script,Google Apps Script,我想获取我域的用户配置文件信息。我正在为此使用配置文件API Profile API只提供了几个字段,如(姓氏、姓名、电子邮件等)…但我也想获得这些字段: 职业、部门、电话[工作]、电话[手机]、关系[经理] 我无法获取这些字段。因此,请给我获取这些字段的建议。应用程序脚本中没有直接用于这些字段的内置API,但如果您将Google应用程序用于商业或教育,您可以通过和使用Google应用程序。这将公开存储在谷歌应用程序中的所有个人资料信息 应用程序脚本中没有直接用于该脚本的内置API,但如果您使用

我想获取我域的用户配置文件信息。我正在为此使用配置文件API

Profile API只提供了几个字段,如(姓氏、姓名、电子邮件等)…但我也想获得这些字段: 职业、部门、电话[工作]、电话[手机]、关系[经理]


我无法获取这些字段。因此,请给我获取这些字段的建议。

应用程序脚本中没有直接用于这些字段的内置API,但如果您将Google应用程序用于商业或教育,您可以通过和使用Google应用程序。这将公开存储在谷歌应用程序中的所有个人资料信息

应用程序脚本中没有直接用于该脚本的内置API,但如果您使用的是用于商业或教育的谷歌应用程序,则可以通过和使用谷歌应用程序。这将公开存储在谷歌应用程序中的所有个人资料信息

我通过配置文件API获得了我的所有字段。。。。实际上,如果任何字段为空,那么概要文件API不会将该字段作为输出。。。。。 因此,使用ProfileAPI,我们可以获得用户的完整信息

Code :
    var username="user "
    var base = 'https://www.google.com/m8/feeds/'; 
    var fetchArgs = googleOAuth_('contacts', base);
    fetchArgs.method='GET'
    var url=base+'profiles/domain/'+domainName+'/full/'+username+'?v=3&alt=json'

    var name=""
    var occupation=""
    var department=""
    var email=""
    var contactNumber_1=""
    var contactNumber_2=""
    var relation=""
    var account=""
    var office=""
    var personal_account=""
    var current_account=""
    var language=""
    var blog=""
    var image=""
    try{
      var urlFetch = UrlFetchApp.fetch(url, fetchArgs)   
      var json=Utilities.jsonParse(urlFetch.getContentText())
      var profileInfo = json.entry
      try{
        name=profileInfo.gd$name.gd$fullName.$t
      }catch(err){}
      try{
        occupation=profileInfo.gContact$occupation.$t
      }catch(err){}
      try{
        department=profileInfo.gd$organization[0].gd$orgDepartment.$t
      }catch(err){}
      try{
        var emaillist=profileInfo.gd$email
        for(var i=0;i<emaillist.length;i++){
          if(emaillist[i].rel.split("#")[1]=='work')
            email=profileInfo.gd$email[i].address
        }
      }catch(err){}
      try{
        var phonelist=profileInfo.gd$phoneNumber
        for(var i=0;i<phonelist.length;i++){
          if(phonelist[i].rel.split("#")[1]=='work')
            contactNumber_1=phonelist[i].$t
          else if(phonelist[i].rel.split("#")[1]=='mobile')
            contactNumber_2=phonelist[i].$t
        }
      }catch(err){}
      try{   
        relation=profileInfo.gContact$relation[0].$t+" ["+profileInfo.gContact$relation[0].rel+"]"
      }catch(err){}  

    }catch(err){}

}


/*
  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"};
}
代码:
var username=“用户”
var base=https://www.google.com/m8/feeds/'; 
var fetchArgs=googleOAuth(“联系人”,基数);
fetchArgs.method='GET'
var url=base+'profiles/domain/'+domainName+'/full/'+username+'?v=3&alt=json'
var name=“”
var occupation=“”
var department=“”
var email=“”
var contactNumber_1=“”
var contactNumber_2=“”
var relation=“”
var account=“”
var office=“”
var personal_account=“”
var活期存款账户=“”
var language=“”
var blog=“”
var image=“”
试一试{
var urlFetch=UrlFetchApp.fetch(url,fetchArgs)
var json=Utilities.jsonParse(urlFetch.getContentText())
var profileInfo=json.entry
试一试{
name=profileInfo.gd$name.gd$fullName.$t
}捕获(错误){}
试一试{
职业=档案信息.gContact$职业。$t
}捕获(错误){}
试一试{
department=profileInfo.gd$组织[0]。gd$组织部门。$t
}捕获(错误){}
试一试{
var emaillist=profileInfo.gd$email

对于(var i=0;i我通过配置文件API获得了我的所有字段……实际上,如果任何字段为空,那么配置文件API不会将该字段作为输出。。。。。 因此,使用ProfileAPI,我们可以获得用户的完整信息

Code :
    var username="user "
    var base = 'https://www.google.com/m8/feeds/'; 
    var fetchArgs = googleOAuth_('contacts', base);
    fetchArgs.method='GET'
    var url=base+'profiles/domain/'+domainName+'/full/'+username+'?v=3&alt=json'

    var name=""
    var occupation=""
    var department=""
    var email=""
    var contactNumber_1=""
    var contactNumber_2=""
    var relation=""
    var account=""
    var office=""
    var personal_account=""
    var current_account=""
    var language=""
    var blog=""
    var image=""
    try{
      var urlFetch = UrlFetchApp.fetch(url, fetchArgs)   
      var json=Utilities.jsonParse(urlFetch.getContentText())
      var profileInfo = json.entry
      try{
        name=profileInfo.gd$name.gd$fullName.$t
      }catch(err){}
      try{
        occupation=profileInfo.gContact$occupation.$t
      }catch(err){}
      try{
        department=profileInfo.gd$organization[0].gd$orgDepartment.$t
      }catch(err){}
      try{
        var emaillist=profileInfo.gd$email
        for(var i=0;i<emaillist.length;i++){
          if(emaillist[i].rel.split("#")[1]=='work')
            email=profileInfo.gd$email[i].address
        }
      }catch(err){}
      try{
        var phonelist=profileInfo.gd$phoneNumber
        for(var i=0;i<phonelist.length;i++){
          if(phonelist[i].rel.split("#")[1]=='work')
            contactNumber_1=phonelist[i].$t
          else if(phonelist[i].rel.split("#")[1]=='mobile')
            contactNumber_2=phonelist[i].$t
        }
      }catch(err){}
      try{   
        relation=profileInfo.gContact$relation[0].$t+" ["+profileInfo.gContact$relation[0].rel+"]"
      }catch(err){}  

    }catch(err){}

}


/*
  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"};
}
代码:
var username=“用户”
var base=https://www.google.com/m8/feeds/'; 
var fetchArgs=googleOAuth(“联系人”,基数);
fetchArgs.method='GET'
var url=base+'profiles/domain/'+domainName+'/full/'+username+'?v=3&alt=json'
var name=“”
var occupation=“”
var department=“”
var email=“”
var contactNumber_1=“”
var contactNumber_2=“”
var relation=“”
var account=“”
var office=“”
var personal_account=“”
var活期存款账户=“”
var language=“”
var blog=“”
var image=“”
试一试{
var urlFetch=UrlFetchApp.fetch(url,fetchArgs)
var json=Utilities.jsonParse(urlFetch.getContentText())
var profileInfo=json.entry
试一试{
name=profileInfo.gd$name.gd$fullName.$t
}捕获(错误){}
试一试{
职业=档案信息.gContact$职业。$t
}捕获(错误){}
试一试{
department=profileInfo.gd$组织[0]。gd$组织部门。$t
}捕获(错误){}
试一试{
var emaillist=profileInfo.gd$email

对于(var i=0;iya,确切地说……我们可以使用Profile API和oAuthya获取用户信息,确切地说……我们可以使用Profile API和oAuth获取用户信息