我必须通过单击按钮将照片发布到“tumblr”。我尝试了以下方式与 tumblr 连接,但不幸的是我没有通过..!
我的回调 URL 正确吗?我的回拨 URL 出现问题。
public class TumblrDemoActivity extends Activity {
private static final String TAG = "TumblrDemo";
private static final String REQUEST_TOKEN_URL = "https://www.tumblr.com/oauth/request_token";
private static final String ACCESS_TOKEN_URL = "https://www.tumblr.com/oauth/access_token";
private static final String AUTH_URL = "https://www.tumblr.com/oauth/authorize";
// Taken from Tumblr app registration
private static final String CONSUMER_KEY = "MY_CONSUMER_KEY";
private static final String CONSUMER_SECRET = "MY_SECRET_KEY";
private static final String CALLBACK_URL = "tumblrdemo://tumblrdemo.com/ok";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// To get the oauth token after the user has granted permissions
Uri uri = this.getIntent().getData();
if (uri != null) {
String token = uri.getQueryParameter("oauth_token");
String verifier = uri.getQueryParameter("oauth_verifier");
Log.v(TAG, "Token:" + token);
Log.v(TAG, "Verifier:" + verifier);
} else {
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
CONSUMER_KEY, CONSUMER_SECRET);
// It uses this signature by default
// consumer.setMessageSigner(new HmacSha1MessageSigner());
CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(
REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTH_URL);
String authUrl;
try {
authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
Log.v(TAG, "Auth url:" + authUrl);
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse(authUrl)));
} catch (OAuthMessageSignerException e) {
Log.v(TAG, "Auth url:" + e.getMessage());
} catch (OAuthNotAuthorizedException e) {
Log.v(TAG, "Auth url:" + e.getMessage());
} catch (OAuthExpectationFailedException e) {
Log.v(TAG, "Auth url:" + e.getMessage());
} catch (OAuthCommunicationException e) {
Log.v(TAG, "Auth url:" + e.getMessage());
}
}
}
/*
* (non-Javadoc)
*
* @see android.app.Activity#onResume()
*/
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.v(TAG, "onResume");
}
}
是否有任何其他 Android SDK 可用于在 tumblr 中共享照片。我究竟做错了什么..?