Skip to content

Commit

Permalink
issue# (TFJ-737)
Browse files Browse the repository at this point in the history
Using API1.1 verify credentials URL if possible.
  • Loading branch information
ApplePedlar committed Dec 20, 2012
1 parent 94d89b0 commit 8f97743
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
* @since Twitter4J 2.1.8
*/
abstract class AbstractImageUploadImpl implements ImageUpload {
public static final String TWITTER_VERIFY_CREDENTIALS_JSON = "https://api.twitter.com/1/account/verify_credentials.json";
public static final String TWITTER_VERIFY_CREDENTIALS_XML = "https://api.twitter.com/1/account/verify_credentials.xml";
@Deprecated
public static final String TWITTER_VERIFY_CREDENTIALS_JSON_V1 = "https://api.twitter.com/1/account/verify_credentials.json";
@Deprecated
public static final String TWITTER_VERIFY_CREDENTIALS_XML_V1 = "https://api.twitter.com/1/account/verify_credentials.xml";

public static final String TWITTER_VERIFY_CREDENTIALS_JSON_V1_1 = "https://api.twitter.com/1.1/account/verify_credentials.json";

private HttpClientWrapper client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "http://img.ly/api/2/upload.json";
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

HttpParameter[] params = {this.image};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "https://api.mobypicture.com/2.0/upload.json";
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

if (null == apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ protected String postUpload() throws TwitterException {

@Override
protected void preUpload() throws TwitterException {
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_XML);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_XML_V1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_XML);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_XML_V1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

if (null == apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "http://posterous.com/api2/upload.json";
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON_V1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON_V1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

HttpParameter[] params = {this.image};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "http://p.twipple.jp/api/upload";
String signedVerifyCredentialsURL = generateVerifyCredentialsAuthorizationURL(TWITTER_VERIFY_CREDENTIALS_XML);
String signedVerifyCredentialsURL = generateVerifyCredentialsAuthorizationURL(TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);

this.postParameter = new HttpParameter[]{
new HttpParameter("verify_url", signedVerifyCredentialsURL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "http://twitgoo.com/api/uploadAndPost";
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON_V1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON_V1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

HttpParameter[] params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "https://twitpic.com/api/2/upload.json";
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON);
String verifyCredentialsAuthorizationHeader = generateVerifyCredentialsAuthorizationHeader(TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);

headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON);
headers.put("X-Auth-Service-Provider", TWITTER_VERIFY_CREDENTIALS_JSON_V1_1);
headers.put("X-Verify-Credentials-Authorization", verifyCredentialsAuthorizationHeader);

if (null == apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected String postUpload() throws TwitterException {
@Override
protected void preUpload() throws TwitterException {
uploadUrl = "https://yfrog.com/api/upload";
String signedVerifyCredentialsURL = generateVerifyCredentialsAuthorizationURL(TWITTER_VERIFY_CREDENTIALS_XML);
String signedVerifyCredentialsURL = generateVerifyCredentialsAuthorizationURL(TWITTER_VERIFY_CREDENTIALS_XML_V1);
Twitter tw = new TwitterFactory().getInstance(this.oauth);

HttpParameter[] params = {
Expand Down

0 comments on commit 8f97743

Please sign in to comment.