Hallo liebes Forum,
Ich möchte mit Hilfe der google+ API meinen Google+ Account auslesen. Ich habe dazu folgendes Codebeispiel aus der Google+ Dokumentation versucht zu implementieren:
Quelle: SampleProgram - google-api-java-client - Short sample program. - Google APIs Client Library for Java - Google Project Hosting
Bei Ausführen des Beispielcodes wird folgende Exception geworfen:
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
at com.google.api.client.json.jackson.JacksonFactory.<init>(JacksonFactory.java:43)
at SocialMediaProject.googleapi.<init>(googleapi.java:21)
at SocialMediaProject.googleapi.main(googleapi.java:37)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
Für die JacksonFactory wird scheinbar noch etwas benötigt vermutlich muss diese Dateien:
http://samples.google-api-java-clie...mdline/src/main/resources/client_secrets.json
irgendwie eingebunden werden. Aber ich habe keine Ahnung wie das gehen soll und die google+ Dokumentation ist auch irgendwie nicht hilfreich. Ich wäre hier für gute Tipps sehr dankbar.
Gruß
Ich möchte mit Hilfe der google+ API meinen Google+ Account auslesen. Ich habe dazu folgendes Codebeispiel aus der Google+ Dokumentation versucht zu implementieren:
Java:
// Set up the HTTP transport and JSON factory
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
// Set up OAuth 2.0 access of protected resources
// using the refresh and access tokens, automatically
// refreshing the access token when it expires
GoogleAccessProtectedResource requestInitializer =
new GoogleAccessProtectedResource(accessToken, httpTransport,
jsonFactory, clientId, clientSecret, refreshToken);
// Set up the main Google+ class
Plus plus = Plus.builder(httpTransport, jsonFactory)
.setHttpRequestInitializer(requestInitializer)
.build();
// Make a request to access your profile and display it to console
Person profile = plus.people().get("me").execute();
System.out.println("ID: " + profile.getId());
System.out.println("Name: " + profile.getDisplayName());
System.out.println("Image URL: " + profile.getImage().getUrl());
System.out.println("Profile URL: " + profile.getUrl());
Quelle: SampleProgram - google-api-java-client - Short sample program. - Google APIs Client Library for Java - Google Project Hosting
Bei Ausführen des Beispielcodes wird folgende Exception geworfen:
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
at com.google.api.client.json.jackson.JacksonFactory.<init>(JacksonFactory.java:43)
at SocialMediaProject.googleapi.<init>(googleapi.java:21)
at SocialMediaProject.googleapi.main(googleapi.java:37)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
Für die JacksonFactory wird scheinbar noch etwas benötigt vermutlich muss diese Dateien:
http://samples.google-api-java-clie...mdline/src/main/resources/client_secrets.json
irgendwie eingebunden werden. Aber ich habe keine Ahnung wie das gehen soll und die google+ Dokumentation ist auch irgendwie nicht hilfreich. Ich wäre hier für gute Tipps sehr dankbar.
Gruß