build fix

This commit is contained in:
Alfonso Lentini 2018-09-23 13:19:48 +02:00
parent 6ff8919dec
commit 419b6e66b1
2 changed files with 29 additions and 29 deletions

View File

@ -4,7 +4,7 @@ import com.github.scribejava.core.builder.api.DefaultApi20;
public class MyApi extends DefaultApi20 {
public MyApi() {
private MyApi() {
}
private static class InstanceHolder {

View File

@ -20,34 +20,34 @@ public class TwitterController {
@GetMapping(value ="/me/twitter")
public String me(HttpServletResponse servletResponse){
try {
OAuth1RequestToken requestToken = service.getService().getRequestToken();
String auth = service.getService().getAuthorizationUrl(requestToken);
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("rundll32 url.dll,FileProtocolHandler " + auth);
} catch (IOException e) {
servletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
System.out.println("Insert twitter code:");
Scanner in = new Scanner(System.in);
String oauthverifier = in.nextLine();
final OAuth1AccessToken accessToken = service.getService().getAccessToken(requestToken,oauthverifier);
OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
service.getService().signRequest(accessToken, request);
Response response = service.getService().execute(request);
return response.getBody();
} catch (IOException | InterruptedException | ExecutionException e) {
servletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
// try {
// OAuth1RequestToken requestToken = service.getService().getRequestToken();
//
// String auth = service.getService().getAuthorizationUrl(requestToken);
//
// Runtime runtime = Runtime.getRuntime();
// try {
// runtime.exec("rundll32 url.dll,FileProtocolHandler " + auth);
// } catch (IOException e) {
// servletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// return null;
// }
//
// System.out.println("Insert twitter code:");
// Scanner in = new Scanner(System.in);
//
// String oauthverifier = in.nextLine();
//
// final OAuth1AccessToken accessToken = service.getService().getAccessToken(requestToken,oauthverifier);
//
// OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
// service.getService().signRequest(accessToken, request);
// Response response = service.getService().execute(request);
// return response.getBody();
//
// } catch (IOException | InterruptedException | ExecutionException e) {
// servletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// }
return null;
}