Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/316.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/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
Java 谷歌OAuth 2联系人服务_Java_Api_Exception_Oauth_Google Contacts Api - Fatal编程技术网

Java 谷歌OAuth 2联系人服务

Java 谷歌OAuth 2联系人服务,java,api,exception,oauth,google-contacts-api,Java,Api,Exception,Oauth,Google Contacts Api,我试图通过谷歌客户端API 1.47.1的jar示例获取所有联系人 为了得到一个新的Contacts服务,我刚创建了一个Auth类 public class Auth { public static class ProfilesManager { private String domain; private String adminEmail; private int batchSize = 100; private List<ContactEntry

我试图通过谷歌客户端API 1.47.1的jar示例获取所有联系人

为了得到一个新的Contacts服务,我刚创建了一个Auth类

public class Auth {


public static class ProfilesManager {

    private String domain;
    private String adminEmail;
    private int batchSize = 100;
    private List<ContactEntry> profiles;
    private ContactsService myService;


    public ProfilesManager(String consumerKey, String consumerSecret, String adminEmail)
        throws OAuthException {

      this.adminEmail = adminEmail;
      this.domain = adminEmail.substring(adminEmail.indexOf('@') + 1);

      GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
      oauthParameters.setOAuthConsumerKey(consumerKey);
      oauthParameters.setOAuthConsumerSecret(consumerSecret);

      this.myService = new ContactsService("GoogleInc-UnshareProfiles-1");
      this.myService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
    }


    public int getBatchSize() {
      return this.batchSize;
    }      
    public void setBatchSize(int value) {
      this.batchSize = value;
    }
    public List<ContactEntry> getProfiles() {
      return this.profiles;
    }


    public void getAllProfiles() throws IOException, ServiceException {
      ArrayList<ContactEntry> profiles = new ArrayList<ContactEntry>();

      URL feedUrl =
          new URL("https://www.google.com/m8/feeds/profiles/domain/" + this.domain
              + "/full?xoauth_requestor_id=" + this.adminEmail);
      while (feedUrl != null) {
        ContactFeed resultFeed = this.myService.getFeed(feedUrl, ContactFeed.class);

        profiles.addAll(resultFeed.getEntries());

        if (resultFeed.getNextLink() != null && resultFeed.getNextLink().getHref() != null
            && resultFeed.getNextLink().getHref().length() > 0) {
          feedUrl = new URL(resultFeed.getNextLink().getHref());
        } else {
          feedUrl = null;
        }
      }
      this.profiles = profiles;
    }

}
公共类身份验证{
公共静态类概要管理器{
私有字符串域;
私人电子邮件;
私有int batchSize=100;
私人名单简介;
私人联系人服务myService;
公共档案管理器(字符串consumerKey、字符串ConsumerCret、字符串adminEmail)
抛出异常{
this.admineal=admineal;
this.domain=adminEmail.substring(adminEmail.indexOf('@')+1);
GoogleOAuthParameters oauthParameters=新的GoogleOAuthParameters();
setOAuthConsumerKey(consumerKey);
setOAuthConsumerCret(ConsumerCret);
this.myService=newcontacts服务(“GoogleInc-UnshareProfiles-1”);
this.myService.setOAuthCredentials(oauthParameters,新的OAuthHmacSha1Signer());
}
public int getBatchSize(){
返回此值。batchSize;
}      
公共空间大小(int值){
此值为0.batchSize=值;
}
公共列表getProfiles(){
返回此.profiles;
}
public void getAllProfiles()引发IOException、ServiceException{
ArrayList profiles=新的ArrayList();
URL提要URL=
新网址(“https://www.google.com/m8/feeds/profiles/domain/“+this.domain
+“/full?xoauth_requestor_id=“+this.adminEmail”);
while(feedUrl!=null){
ContactFeed resultFeed=this.myService.getFeed(feedUrl,ContactFeed.class);
profiles.addAll(resultFeed.getEntries());
如果(resultFeed.getNextLink()!=null&&resultFeed.getNextLink().getHref()!=null
&&resultFeed.getNextLink().getHref().length()>0){
feedUrl=新URL(resultFeed.getNextLink().getHref());
}否则{
feedUrl=null;
}
}
this.profiles=profiles;
}
}
}

但创建ContactsService的新实例时,此代码会生成一个异常:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at google.Auth$ProfilesManager.<init>(Auth.java:43)
at main.Main.main(Main.java:16)
线程“main”java.lang.NoClassDefFoundError中的异常:com/google/common/collect/Maps 在com.google.gdata.wireformats.AltRegistry上(AltRegistry.java:118) 在com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:100) 在com.google.gdata.client.Service.(Service.java:555) 在google.Auth$ProfilesManager(Auth.java:43) 在main.main.main(main.java:16)
您是否包括google collections jar?这是所有依赖项列表的链接,谢谢,guava-18.0.jar确实提供了帮助