基本信息
源码名称:android开发新浪微博客户端
源码大小:2.72M
文件格式:.rar
开发语言:Java
更新时间:2015-05-11
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 5 元×
微信扫码支付:5 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
package weibo4andriod.examples; import java.io.*; import java.net.*; import weibo4andriod.Status; import weibo4andriod.Weibo; import weibo4andriod.http.ImageItem; public class Upload { public static void main(String args[]){ try{ System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY); System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET); Weibo weibo = new Weibo(); weibo.setToken(args[0], args[1]); try{ byte[] content= readFileImage(args[2]); System.out.println("content length:" content.length); ImageItem pic=new ImageItem("pic",content); String url1=java.net.URLEncoder.encode("穿梭,时光。回到,最初。然后,穿越。在穿越,穿越,回到500年前,大闹天宫。 ","UTF-8"); System.out.println("" url1); Status status=weibo.uploadStatus(url1, pic); System.out.println("Successfully upload the status to [" status.getText() "]."); } catch(Exception e1){ e1.printStackTrace(); } }catch(Exception ioe){ System.out.println("Failed to read the system input."); } } public static byte[] readFileImage(String filename)throws IOException{ BufferedInputStream bufferedInputStream=new BufferedInputStream( new FileInputStream(filename)); int len =bufferedInputStream.available(); byte[] bytes=new byte[len]; int r=bufferedInputStream.read(bytes); if(len !=r){ bytes=null; throw new IOException("读取文件不正确"); } bufferedInputStream.close(); return bytes; } }