我是新手将twitter集成到android中。在我的应用程序中,我想在推特上传照片。
我不确定它是如何可能的,但我发现在twitter网站上的推文期间上传了照片选项。所以我想在那条推文中上传照片。
是否有任何示例或演示可以集成它? 请给我链接到任何演示项目或示例。 感谢。
更新
在twit4j之后实现get错误:
11-12 10:36:19.384: WARN/System.err(283): org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found
11-12 10:36:19.394: WARN/System.err(283): at org.apache.harmony.xml.ExpatParser.finish(ExpatParser.java:553)
11-12 10:36:19.404: WARN/System.err(283): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:483)
11-12 10:36:19.404: WARN/System.err(283): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:320)
11-12 10:36:19.416: WARN/System.err(283): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:277)
11-12 10:36:19.416: WARN/System.err(283): at com.harrison.lee.twitpic4j.ResponseXMLParser.parseResponse(ResponseXMLParser.java:81)
11-12 10:36:19.416: WARN/System.err(283): at com.harrison.lee.twitpic4j.TwitPic.uploadAndPost(TwitPic.java:170)
11-12 10:36:19.416: WARN/System.err(283): at com.example.drawing.DrawingActivity.onClick(DrawingActivity.java:408)
11-12 10:36:19.424: WARN/System.err(283): at java.lang.reflect.Method.invokeNative(Native Method)
11-12 10:36:19.424: WARN/System.err(283): at java.lang.reflect.Method.invoke(Method.java:521)
11-12 10:36:19.424: WARN/System.err(283): at android.view.View$1.onClick(View.java:2067)
11-12 10:36:19.435: WARN/System.err(283): at android.view.View.performClick(View.java:2408)
11-12 10:36:19.435: WARN/System.err(283): at android.view.View$PerformClick.run(View.java:8816)
11-12 10:36:19.435: WARN/System.err(283): at android.os.Handler.handleCallback(Handler.java:587)
11-12 10:36:19.483: WARN/System.err(283): at android.os.Handler.dispatchMessage(Handler.java:92)
11-12 10:36:19.483: WARN/System.err(283): at android.os.Looper.loop(Looper.java:123)
11-12 10:36:19.483: WARN/System.err(283): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-12 10:36:19.483: WARN/System.err(283): at java.lang.reflect.Method.invokeNative(Native Method)
11-12 10:36:19.483: WARN/System.err(283): at java.lang.reflect.Method.invoke(Method.java:521)
11-12 10:36:19.494: WARN/System.err(283): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-12 10:36:19.494: WARN/System.err(283): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-12 10:36:19.494: WARN/System.err(283): at dalvik.system.NativeStart.main(Native Method)
11-12 10:36:19.494: INFO/System.out(283): Status: null
11-12 10:36:19.506: INFO/System.out(283): Status Id: null
11-12 10:36:19.506: INFO/System.out(283): User Id: null
11-12 10:36:19.506: INFO/System.out(283): Media Aid: null
11-12 10:36:19.506: INFO/System.out(283): Media Url: null
11-12 10:36:19.514: INFO/System.out(283): Error Code: null
11-12 10:36:19.514: INFO/System.out(283): Error Msg: null
答案 0 :(得分:1)
是的,这是可能的。你需要一个jar文件twitpic4j.jar
http://code.google.com/p/twitpic4j/downloads/detail?name=twitpic4j.jar&can=2&q=
这是代码;请确保您已使用tweetpic帐户注册了您的Twitter帐户。
File file = ***YOUR IMAGE***
TwitPic tpRequest = new TwitPic(this.username, this.password);
TwitPicResponse tpResponse = null;
// Make request and handle exceptions
try {
tpResponse = tpRequest.uploadAndPost(file, this.tweet);
return "s";
} catch (IOException e) {
e.printStackTrace();
} catch (TwitPicException e) {
e.printStackTrace();
}
答案 1 :(得分:1)