我正试图在我的应用程序中利用该网站http://www.rossnet.pl/Start.aspx的时事通讯唱歌。我正在尝试在我的 Android 应用程序中发送 POST 数据,一切看起来都很好,但电子邮件仍然不在时事通讯列表中。我的代码:
public class MainActivity extends Activity {
private Button b;
private int TIMEOUT_MS = 10000;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair(
"dnn_ctr1741_ViewNewsletterSubscribe_tb_hidden",
"k.o.p.t.u.s@gmail.com"));
nameValuePairs
.add(new BasicNameValuePair(
"__EVENTVALIDATION",
"/wEWCwLbrPQDApzVwckKApul3dEEArGyrMYCAq6r4NoEAujm+N8IApWbjNwEAsHhzqkPAqD4jIQPAv7k8bICAtH1idgOYOyKdndX8LHZqHjXpX5IdUMCNvc="));
nameValuePairs.add(new BasicNameValuePair("__EVENTTARGET",
"dnn$ctr1741$ViewNewsletterSubscribe$lbtn_subscribe"));
nameValuePairs.add(new BasicNameValuePair("dnn$ctr1741$ViewNewsletterSubscribe$tb_hidden",
"k.o.p.t.u.s@gmail.com"));
nameValuePairs.add(new BasicNameValuePair("ScriptManager_TSM",
";;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:en:111e8464-2436-44db-9b34-0d84ed5253c8:ea597d4b:b25378d2"));
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(
client.getParams(), TIMEOUT_MS);
HttpConnectionParams.setSoTimeout(client.getParams(),
TIMEOUT_MS);
HttpPost post = new HttpPost("http://www.rossnet.pl/Start.aspx");
try {
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.d("debug", "lala1");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // with list of key-value pairs
try {
Log.d("debug", "test1");
client.execute(post, new ResponseHandler(){
public Object handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
Log.d("debug", "test2");
return null;
}});
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d("debug", "test3");
}
});
}
}