vendredi 8 mai 2015

Daten via Post an php Script senden

Hallo,
ich versuche mit folgenden Script Daten an ein php-Script via POSt zu versenden, ohne Erfolg,. Als GET angehangen gehts...

JAVA
Java Code:

  1.  
  2. import java.io.*;
  3. import java.net.*;
  4. public class UrlLader2 {
  5.  
  6. public static void main( String[] args ){
  7.  
  8. OutputStream os = null;
  9. InputStream is = null;
  10.  
  11.  
  12. try {
  13.  
  14. // Connection:
  15. URL url = new URL( "http://ift.tt/1uWPA5J; );
  16. URLConnection con = url.openConnection();
  17. if( !(con instanceof HttpURLConnection) ) {
  18. throw new Exception( "Error: Only HTTP allowed." );
  19. }
  20. ((HttpURLConnection) con).setRequestMethod( "POST" );
  21. con.setDoOutput( true );
  22. // Send data:
  23. os = con.getOutputStream();
  24. os.write( "hallo von java ".getBytes() );
  25. os.flush();
  26. // Read response:
  27. is = con.getInputStream();
  28. int len;
  29. byte[] buff = new byte[4096];
  30. while( -1 != (len = is.read( buff )) ) {
  31. System.out.print( new String( buff, 0, len ) );
  32. }
  33. System.out.println();
  34. }
  35. catch( Exception ex ) {
  36. System.out.println( "\nError: " + ex );
  37. }
  38. }
  39. }


KONSOLE
HTML-Code:

Successfully dumped 0 post variables.View it at http://ift.tt/1F9EzE1 body was 0 chars long.
Das sagt die PHP-Seite
HTML-Code:

...
Headers (Some may be inserted by server)
REQUEST_URI = /post.php
QUERY_STRING =
REQUEST_METHOD = POST
GATEWAY_INTERFACE = CGI/1.1
REMOTE_PORT = 50334
REMOTE_ADDR = 84.131.70.236
CONTENT_LENGTH = 15
CONTENT_TYPE = application/x-www-form-urlencoded
HTTP_CONNECTION = close
HTTP_ACCEPT = text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
HTTP_HOST = posttestserver.com
HTTP_USER_AGENT = Java/1.8.0_45
UNIQUE_ID = VUyYptBx6hIAAATQ7tUAAAAD
REQUEST_TIME_FLOAT = 1431083174.0741
REQUEST_TIME = 1431083174

No Post Params.
Empty post body.

Upload contains PUT data: hallo von java

No Post Params? Warum?

Gruss Rammi


Daten via Post an php Script senden

0 commentaires:

Enregistrer un commentaire