List of usage examples for twitter4j.auth OAuthAuthorization encodeParameters
public static String encodeParameters(List<HttpParameter> httpParams, String splitter, boolean quot)
From source file:cmu.edu.homework.mediaUpload.AbstractPhotoUploadImpl.java
License:Apache License
String generateVerifyCredentialsAuthorizationHeader() { List<HttpParameter> oauthSignatureParams = oauth.generateOAuthSignatureHttpParams("GET", AbstractPhotoUploadImpl.TWITTER_VERIFY_CREDENTIALS_JSON_V1_1); return "OAuth realm=\"https://api.twitter.com/\"," + OAuthAuthorization.encodeParameters(oauthSignatureParams, ",", true); }
From source file:cmu.edu.homework.mediaUpload.AbstractVideoUploadImpl.java
License:Apache License
String generateVerifyCredentialsAuthorizationHeader(String method) { List<HttpParameter> oauthSignatureParams = oauth.generateOAuthSignatureHttpParams(method, AbstractVideoUploadImpl.TWITTER_VERIFY_CREDENTIALS_JSON_V1_1); return "OAuth realm=\"https://api.twitter.com/\"," + OAuthAuthorization.encodeParameters(oauthSignatureParams, ",", true); }
From source file:com.dwdesign.tweetings.service.TweetingsService.java
License:Open Source License
public String generateOAuthEchoHeader(final long account_id) { final Twitter twitter = getTwitterInstance(TweetingsService.this, account_id, false); if (twitter != null) { Authorization authorization = twitter.getAuthorization(); if (!(authorization instanceof OAuthAuthorization)) { throw new IllegalArgumentException("OAuth authorization is required."); }//from w ww .j a v a2 s . co m OAuthAuthorization oauth = (OAuthAuthorization) authorization; List<HttpParameter> oauthSignatureParams = oauth.generateOAuthSignatureHttpParams("GET", TWITTER_VERIFY_CREDENTIALS_JSON); return "OAuth realm=\"http://api.twitter.com/\"," + OAuthAuthorization.encodeParameters(oauthSignatureParams, ",", true); } return null; }
From source file:de.vanita5.twittnuker.util.shortener.TweetShortenerUtils.java
License:Open Source License
/** * Gets the header to verify the user on Twitter * twitter4j//ww w . j a v a 2s .c o m * @param twitter Coming from Twitter.getInstance() * @return String of the header to be used with X-Verify-Credentials-Authorization */ public static String getHeader(Twitter twitter) { try { final long timestamp = System.currentTimeMillis() / 1000; Random rand = new Random(); final long nonce = timestamp + rand.nextInt(); final List<HttpParameter> oauthHeaderParams = new ArrayList<HttpParameter>(5); oauthHeaderParams.add(new HttpParameter("oauth_consumer_key", TWITTER_CONSUMER_KEY_2)); oauthHeaderParams.add(new HttpParameter("oauth_signature_method", "HMAC-SHA1")); oauthHeaderParams.add(new HttpParameter("oauth_timestamp", timestamp)); oauthHeaderParams.add(new HttpParameter("oauth_nonce", nonce)); oauthHeaderParams.add(new HttpParameter("oauth_version", "1.1")); if (twitter.getOAuthAccessToken() != null) { oauthHeaderParams.add(new HttpParameter("oauth_token", twitter.getOAuthAccessToken().getToken())); } final List<HttpParameter> signatureBaseParams = new ArrayList<HttpParameter>(oauthHeaderParams.size()); signatureBaseParams.addAll(oauthHeaderParams); parseGetParameters(OAUTH_SERVICE_PROVIDER, signatureBaseParams); final StringBuffer base = new StringBuffer("GET").append("&") .append(HttpParameter.encode(constructRequestURL(OAUTH_SERVICE_PROVIDER))).append("&"); base.append(HttpParameter.encode(normalizeRequestParameters(signatureBaseParams))); final String oauthBaseString = base.toString(); final String signature = generateSignature(oauthBaseString, twitter.getOAuthAccessToken()); oauthHeaderParams.add(new HttpParameter("oauth_signature", signature)); return "OAuth realm=\"http://api.twitter.com/\"," + OAuthAuthorization.encodeParameters(oauthHeaderParams, ",", true); } catch (TwitterException e) { e.printStackTrace(); } return null; }
From source file:org.socialnetlib.android.TwitterApi.java
License:Apache License
public String generateTwitterVerifyCredentialsAuthorizationHeader() { String verifyCredentialsUrl = TWITTER_VERIFY_CREDENTIALS_JSON; List<HttpParameter> oauthSignatureParams = mOAuth.generateOAuthSignatureHttpParams("GET", verifyCredentialsUrl);//from w w w. j a va 2s . c o m return "OAuth realm=\"https://api.twitter.com/\"," + OAuthAuthorization.encodeParameters(oauthSignatureParams, ",", true); }