Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String args[]) throws MalformedURLException, IOException, JSONException{
- String urlParameters = "username=14650015&password=admin";
- byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 );
- int postDataLength = postData.length;
- String request = "http://ios.pdef.space/auth.php";
- URL url = new URL( request );
- HttpURLConnection conn= (HttpURLConnection) url.openConnection();
- conn.setDoOutput( true );
- conn.setInstanceFollowRedirects( false );
- conn.setRequestMethod( "POST" );
- conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
- conn.setRequestProperty( "charset", "utf-8");
- conn.setRequestProperty( "Content-Length", Integer.toString( postDataLength ));
- conn.setUseCaches( false );
- try( DataOutputStream wr = new DataOutputStream( conn.getOutputStream())) {
- wr.write( postData );
- BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
- String output =br.readLine();
- // Mendapatkan Hasil Dari JSON Standard
- JSONObject json = new JSONObject(output);
- // Membuat Object
- //JSONObject presensi = json.getJSONObject("presensi");
- // Membaca Data Latest Update
- String message = json.getString("message");
- System.out.print("Status Login : ");
- System.out.println(message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement