我需要将3个下拉值从我的应用传递到网站链接http://www.way2franchise.com/ 说:广告和媒体,选择投资,选择国家。是我的3个价值观 我需要传递给搜索过滤器链接: http://www.way2franchise.com/search/filter_franchise
P.S:我不能发布超过2个链接,因为stackoverflow限制了这个链接
在讨论中有两个链接:
1.网站链接
2.搜索过滤器链接。
public class DatafetchingActivity extends Activity {
TextView result;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
result = (TextView) findViewById(R.id.result);
BufferedReader bufferedReader = null;
HttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost("http://www.way2franchise.com/search/filter_franchise");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("p", "advertisement_and_media"));
postParameters.add(new BasicNameValuePair("q", "Select Industry"));
postParameters.add(new BasicNameValuePair("r", "Select Industry"));
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
postParameters);
request.setEntity(entity);
HttpResponse response = httpClient.execute(request);
bufferedReader = new BufferedReader(new InputStreamReader(response
.getEntity().getContent()));
StringBuffer stringBuffer = new StringBuffer("");
String line = "";
String LineSeparator = System.getProperty("line.separator");
while ((line = bufferedReader.readLine()) != null) {
stringBuffer.append(line + LineSeparator);
}
bufferedReader.close();
result.setText(stringBuffer.toString());
Toast.makeText(DatafetchingActivity.this, "Finished",
Toast.LENGTH_LONG).show();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(DatafetchingActivity.this, e.toString(),
Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(DatafetchingActivity.this, e.toString(),
Toast.LENGTH_LONG).show();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
} 现在,此输出提供搜索过滤器的整个结果。它的输出与我复制并粘贴搜索过滤器链接的输出相同。
但那不是我想要的。
我需要的是,如果我打开链接(不是搜索过滤器链接),并选择广告和媒体选项,选择投资,选择状态。我应该只根据传递的选项值得到结果。
答案 0 :(得分:1)
以下代码:
postParameters.add(new BasicNameValuePair("p", "advertisement_and_media"));
postParameters.add(new BasicNameValuePair("q", "Select Industry"));
postParameters.add(new BasicNameValuePair("r", "Select Industry"));
这里有三个名称值对,即p,q,r。这些是在服务器上接收值的键。所以无论你用密钥“p”,“q”,“r”发送什么,数据都将是在服务器端收到那些键/值对。
希望我回答你的问题。