Source code is as follows:

package com.chinaclick.yummy.weibo.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.sun.mail.imap.Utility;

import weibo4j.Oauth;
import weibo4j.Timeline;
import weibo4j.Users;
import weibo4j.Weibo;
import weibo4j.http.AccessToken;
import weibo4j.model.Status;
import weibo4j.model.User;
import weibo4j.model.WeiboException;

public class WeiboManageAction extends DispatchAction {

	
	public ActionForward loadUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println("Come in.");
		/*String code = request.getParameter("code"); Println (" secret "+code); Oauth oauth = new Oauth(); String value = oauth.authorize("code"); //Utility.setAuthorization(new Oauth2AccessTokenHeader()); / / get accessToken value, and then get in the API applicable access_token accessToken accessToken = request. GetAccessTokenByCode (code); String access_token = accessToken.getAccessToken(); // Get important access_token */	  	/*String access_token = request.getParameter("access_token"); AccessToken accessToken = String uid = accessToken.getUid(); Uid Users Users = new Users(); // get call User User = users.showuserbyid (uid); Println (" user.getScreenName() +user.getScreenName()); //accessToken.getUid(); request.setAttribute("access_token",access_token); request.setAttribute("user", user); * /
		String uid = request.getParameter("uid");
		Users users = new Users();
		User user =users.showUserById(uid);
		String access_token = request.getParameter("access_token");
		request.setAttribute("user", user);
		request.setAttribute("access_token", access_token);
		return mapping.findForward("user");
	}
	// Weibo releases information
	public ActionForward releaseMsg(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String access_token = request.getParameter("access_token");
		String statuses = request.getParameter("statuses");
		//String statuses = "test admin ";
		System.out.println("----access_token-----"+access_token);
		System.out.println("----statuses-----"+statuses);
		Weibo weibo = new Weibo();  
		weibo.setToken(access_token);  
		Timeline tm = new Timeline();  
		try {  
		    Status status = tm.UpdateStatus(statuses);  
		   // Log.logInfo(status.toString());  
		    System.out.println("User information :");
		    System.out.println("Nickname."+status.getUser().getScreenName());
		    System.out.println("User information :");
		} catch (WeiboException e) {  
		    e.printStackTrace();  
		} 
		//request.setAttribute("location", arg1);
		return mapping.findForward("ok");
	}
	public ActionForward redirect(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String access_token = request.getParameter("access_token");
		request.setAttribute("access_token", access_token);
		return mapping.findForward("releaseMsg"); }}Copy the code

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: