如何通过Android中的http帖子发布Web链接

时间:2014-03-11 05:50:46

标签: android

我想在我的应用中发布网络链接,我尝试了以下代码。

 HttpClient httpclient = new DefaultHttpClient();
     HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
     HttpResponse response = httpclient.execute(httppost);

但它不起作用。 帮帮我

2 个答案:

答案 0 :(得分:0)

HttpResponse response = (HttpResponse) httpclient
                .execute(httpPostRequest);

使用此代码......我希望它对您有用。

请在androidmanifest文件中添加权限

  <uses-permission android:name="android.permission.INTERNET" />

答案 1 :(得分:0)

这个怎么样?

HttpClient httpclient = new DefaultHttpClient();
     HttpPost httppost = new HttpPost("\http://www.yoursite.com/script.php\");
     HttpResponse response = httpclient.execute(httppost);