public MessageData getMessage(String appid,int type) throws Exception
	{
		MessageData messageData = null;
		String extension="";
		switch(type)
		{
		case ALERT:
			
			
		case MESSAGE:
			
		case UPDATE:
			extension = appid+"/"+type;
			break;
		default:
			
			
		}
		//System.out.println("URL is "+url+extension);
		String JSONdata = getJSON(url+extension);
		JSONParser parser=new JSONParser();
		Object obj;
		try {
			obj = parser.parse(JSONdata);
			JSONObject result = (JSONObject)obj;
			//System.out.println("Message is "+result);
			result = (JSONObject)((JSONArray)result.get("data")).get(0);
			String validtill = result.get("validTill").toString();
			if(!validtill.equals("None"))
			{
				Calendar now = Calendar.getInstance();
				int year = now.get(Calendar.YEAR);
				int month = now.get(Calendar.MONTH); // Note: zero based!
				int day = now.get(Calendar.DAY_OF_MONTH);
				int cyear = Integer.parseInt(validtill.split("-")[2]);
				int cmonth = Integer.parseInt(validtill.split("-")[1]);
				int cday = Integer.parseInt(validtill.split("-")[0]);
				if(year>cyear || day>cday || month > cmonth)
				{
					throw new ValidityExpired();
				}
				
				
				
			}
			messageData = new MessageData(result.get("msg").toString(), Integer.parseInt(result.get("mtype").toString()), result.get("validTill").toString());
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			throw new MessageNotFound();
		}
		
		return messageData;
	}