0

サーバーへの投稿をスリムにするのは初めてです(phpなし)

www.myLink.com/user/ID1/value のようなリンクにリクエストを投稿する必要があります。id はユーザー ID で、value は文字列です。

どうすれば投稿できますか?

私は試してみました

HttpClient client = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(" http://myLink.com/user/");  
        try {
             // Add data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("ID", "id1"));
            nameValuePairs.add(new BasicNameValuePair("VALUE", "The value to post"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request
            HttpResponse response = client.execute(httppost);
            System.out.println("return della post " + response);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }

しかし、働かないでください。私はこのエラーを持っています:

08-02 12:46:26.507: W/System.err(26293): java.lang.IllegalArgumentException: Illegal character in scheme at index 0:  http://karaoke.eu01.aws.af.cm/endpoints.php/user/facebook-share/
08-02 12:46:26.507: W/System.err(26293):    at java.net.URI.create(URI.java:727)
08-02 12:46:26.507: W/System.err(26293):    at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:79)

投稿してもいいですか?

4

0 に答える 0