protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String flag=(String)request.getParameter("flag");
String accessToken=(String)request.getSession().getAttribute("access_token");
if(flag!=null&&accessToken!=null&&!"".equals(flag)&&!"".equals(accessToken)){
RenrenApiClient client=RenrenApiClient.getInstance();
if(flag.equals("local")){
//上传本地图片
String filename=(String)request.getParameter("filename");
filename=new String(filename.getBytes("ISO8859-1"),"UTF-8");
try{
client.getPhotoService().uploadLocalImg(0, filename, "测试上传本地图片"+new Date(),new AccessToken(accessToken));
}catch(Exception e){
request.setAttribute("errMsg", e.getMessage());
RequestDispatcher welcomeDispatcher = request.getRequestDispatcher("/views/error.jsp");
welcomeDispatcher.forward(request, response);
}
}else if(flag.equals("url")){
//上传网络图片
String fileurl=(String)request.getParameter("fileurl");
try{
client.getPhotoService().uploadURLImg(0, fileurl, "测试上传网络图片"+new Date(),new AccessToken(accessToken));
}catch(Exception e){
request.setAttribute("errMsg", e.getMessage());
RequestDispatcher welcomeDispatcher = request.getRequestDispatcher("/views/error.jsp");
welcomeDispatcher.forward(request, response);
}