首页 > 代码库 > 微博API常用方法

微博API常用方法

1.获取24小时内前20条用户的微博信息

List<Status> statuses = weibo.getFriendsTimeline();
for (Status status : statuses) 
{
	System.out.println(status.getUser().getName() + ":" +status.getId()+":"+ 
	status.getText() + status.getOriginal_pic()); 
}

2.用户

public static void getLoginUser()
{
	try
	{
		User user =weibo.showUser(USER_ID);
		
		System.out.println(user.getName());
		System.out.println(user.getCity());
		System.out.println(user.getFriendsCount());
		System.out.println(user.getScreenName());
		System.out.println(user.getProfileImageURL().toString());
	}
	catch (WeiboException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

3.发表微博

public static void updateStatus() throws Exception
{
    Status status= weibo.updateStatus("新浪微博Android开发视频测试微博!!!!");	
    System.out.println(status.getId() + " : "+ status.getText()+"  "+status.getCreatedAt());
}	

  

  

微博API常用方法