2012-04-18 5 views
0

blahNow私は、私のアプリでは、私のアプリでログインする必要があります... www.blah.com/api/login/username/passwordをANdroidのアプリケーションを実行しています。は、サイトにアンドロイドからデータを渡します

private void sendAccelerationData() 
{ 
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7); 
    nameValuePairs.add(new BasicNameValuePair("","test3")); 
    nameValuePairs.add(new BasicNameValuePair("","pass3")); 
    this.sendData(nameValuePairs); 
} 

private void sendData(ArrayList<NameValuePair> data) 
{ 
    try 
    { 
     HttpClient httpclient = new DefaultHttpClient(); 
     HttpPost httppost = new  
     HttpPost("http://blah.com/api/login/"); 
     httppost.setEntity(new UrlEncodedFormEntity(data)); 
     HttpResponse response = httpclient.execute(httppost); 
    } 
} 

が、私は

HttpPost("http://eesnap.com"); 

とsendAccelerationData(のように私のsendData()を書く場合、私はerror.and 404を取得しています)

nameValuePairs.add(new BasicNameValuePair("","api")); 
nameValuePairs.add(new BasicNameValuePair("","login")); 
nameValuePairs.add(new BasicNameValuePair("","test3")); 
nameValuePairs.add(new BasicNameValuePair("","pass3")); 

ように私は200人の成功を取得しています。 ブラウワーのポストwww.blah.com/api/login/username/passwordが、私は、ブラウザ上で結果を取得していた場合

答えて

0

私error.In GET」() 'メソッド私は上記のようなコードを書くことができますが、postメソッドで私は名前の値のペアを使用する必要があります。

1

試してみてください。私は理解して

HttpPost("http://www.blah.com/api/login/"); 
+0

http://eesnap.com/api/login/test3/pass3.Copy this url on addressbar ....確認できます – sarath

関連する問題