如果我尝试使用 TwitPic 将图像发送到 Twitter。
这是我的方法onCreate:
...
Config.configObject().setAddThisPubId("...");
Config.configObject().setAddThisAppId("...");
Config.configObject().setShouldUseTwitterOAuth(true);
Config.configObject().setTwitterViaText("Title");
Config.configObject().setTwitterConsumerKey("...");
Config.configObject().setTwitterConsumerSecret("...");
Config.configObject().setTwitPicApiKey("...");
Config.configObject().setTwitterCallbackUrl(
"http://addthis.com/mobilesdk/twittertesting");
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Bitmap bmpImage = BitmapFactory.decodeStream(getAssets()
.open("image.png"));
AddThis.shareItem(MainActivity.this, "twitter", "Title",
"Description", bmpImage);
} catch (IOException e1) {
e1.printStackTrace();
} catch (ATDatabaseException e) {
e.printStackTrace();
} catch (ATSharerException e) {
e.printStackTrace();
}
}
});
...
当我尝试分享时,logcat 打印:
11-09 15:35:03.230: I/Activity Group(4646): Service = twitter
11-09 15:35:03.230: I/Activity Group(4646): Service = twitter
11-09 15:35:03.230: I/Activity Group(4646): LoadViews
11-09 15:35:03.230: I/ATTwitter(4646): Already authenticated
11-09 15:35:03.240: D/dalvikvm(4646): GC_EXTERNAL_ALLOC freed 155K, 49% free 2783K/5447K, external 930K/1038K, paused 10ms
11-09 15:35:07.590: D/dalvikvm(4646): GC_FOR_MALLOC freed 298K, 50% free 2925K/5767K, external 1037K/1532K, paused 0ms
11-09 15:35:09.620: I/ATTwitter(4646): Inside async taskTitle: Description via @Cocktail maker: http://twitpic.com/bbnwvm
11-09 15:35:09.780: D/dalvikvm(4646): GC_FOR_MALLOC freed 179K, 48% free 3081K/5895K, external 973K/1485K, paused 10ms
11-09 15:35:10.500: I/global(4646): Loaded time zone names for en_US in 100ms.
11-09 15:35:10.530: E/TwitterConnector(4646): 404: Not Found
并显示 Toast 消息:
Couldnot complete the share, please try again later.
有时 Logcat 打印:
11-09 15:40:05.130: I/Activity Group(4714): Service = twitter
11-09 15:40:05.130: I/Activity Group(4714): Service = twitter
11-09 15:40:05.140: I/Activity Group(4714): LoadViews
11-09 15:40:05.160: D/dalvikvm(4714): GC_CONCURRENT freed 160K, 46% free 3115K/5767K, external 1315K/1564K, paused 0ms+0ms
11-09 15:40:05.160: I/ATTwitter(4714): Already authenticated
11-09 15:40:05.170: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:05.170: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:06.630: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:06.630: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:06.850: D/dalvikvm(4714): GC_FOR_MALLOC freed 325K, 46% free 3398K/6215K, external 1315K/1564K, paused 10ms
11-09 15:40:06.880: D/dalvikvm(4714): GC_CONCURRENT freed 10K, 46% free 3406K/6215K, external 1315K/1564K, paused 0ms+0ms
11-09 15:40:08.420: W/DefaultRequestDirector(4714): Authentication error: Unable to respond to any of these challenges: {}
11-09 15:40:08.420: E/Twitpic(4714): 401: Unauthorized
11-09 15:40:08.420: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:08.420: I/ATTwitter(4714): Inside async taskBerry Mule: 35 ml Funkin Mixed Berry Puree
11-09 15:40:08.420: I/ATTwitter(4714): 20 ml Funkin Pure Pour Lime
11-09 15:40:08.420: I/ATTwitter(4714): 50 ml Vodka
11-09 15:40:08.420: I/ATTwitter(4714): 50 ml Ginger Beer via @Cocktail maker
11-09 15:40:08.420: D/Resources(4714): returning fake Configuration with orientation changed to portrait
11-09 15:40:09.380: I/global(4714): Loaded time zone names for en_US in 90ms.
11-09 15:40:09.390: W/DefaultRequestDirector(4714): Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="http://twitter.com"}
11-09 15:40:09.390: E/TwitterConnector(4714): 401: Unauthorized
为什么会这样?有人有想法吗?