2
我想從AndroidHTTP POST請求的Android
聯繫的API我發現這個示例代碼...
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
我的問題是,我怎麼能看到,以確保它是響應得到一個?有沒有添加API密鑰的方法?
此外,「yoursite.com」必須是PHP文件嗎?
服務器不必在php中使用任何你想在服務器端。我們使用python和Django。 – sww314 2012-07-10 22:36:28