Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android在slim服务器上发布_Android_Post_Slim - Fatal编程技术网

android在slim服务器上发布

android在slim服务器上发布,android,post,slim,Android,Post,Slim,这是我第一次在slim服务器上发表文章(没有php) 我必须在www.myLink.com/user/ID1/value这样的链接上发布请求 其中id是用户id,值是字符串 我怎样才能到邮局 我试过了 HttpClient client = new DefaultHttpClient(); HttpPost httppost = new HttpPost(" http://myLink.com/user/"); try { // Ad

这是我第一次在slim服务器上发表文章(没有php)

我必须在www.myLink.com/user/ID1/value这样的链接上发布请求 其中id是用户id,值是字符串

我怎样才能到邮局

我试过了

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
        }
HttpClient=newdefaulthttpclient();
HttpPost HttpPost=新的HttpPost(“http://myLink.com/user/");  
试一试{
//添加数据
List nameValuePairs=新的ArrayList(2);
添加(新的BasicNameValuePair(“ID”、“id1”);
添加(新的BasicNameValuePair(“值”、“要发布的值”);
setEntity(新的UrlEncodedFormEntity(nameValuePairs));//执行HTTP Post请求
HttpResponse response=client.execute(httppost);
System.out.println(“返回della post”+响应);
}捕获(客户端协议例外e){
//TODO自动生成的捕捉块
}捕获(IOE异常){
//TODO自动生成的捕捉块
}
但是不要工作。 我有一个错误:

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)
08-02 12:46:26.507:W/System.err(26293):java.lang.IllegalArgumentException:索引0处的方案中存在非法字符:http://karaoke.eu01.aws.af.cm/endpoints.php/user/facebook-share/
08-02 12:46:26.507:W/System.err(26293):位于java.net.URI.create(URI.java:727)
08-02 12:46:26.507:W/System.err(26293):位于org.apache.http.client.methods.HttpPost.(HttpPost.java:79)

我能发帖子吗?

你的URL开头好像有空白?这可能是编译器抱怨的字符?谢谢。。我是个白痴。。。现在我有一条消息返回della post:org.apache.http.message。BasicHttpResponse@42993db8我怎样才能知道插入是否正确?您应该使用获得的BasicHttpResponse中的getStatusLine()函数:然后需要使用getStatusCode()从您获取的StatusLine对象中,将其与200进行比较,以了解请求是否成功。获取状态为404(未找到?),您可以显示StatusLine的内容吗?