문제

I need to pass 3 drop down values from my app to the website link http://www.way2franchise.com/ say: Advertisement and media,select investment,select state. Are my 3 values.
I need to pass to the search filter link: http://www.way2franchise.com/search/filter_franchise.

P.S: i cannot post more than 2 links as restricted by stackoverflow.
In discussion there a re two links:
1. the website link
2.search filter link.

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();
            }
        }
    }

}

} Now,this output gives the entire result of search filter.Its the same output as if i copied and pasted the search filter link.

But that's not what i want.

what i need is , if i open the link(not the search filter link),and chose the options Advertisement and media,select investment,select state. I should get only get the results based on the options value passed.

도움이 되었습니까?

해결책

The following code:


    postParameters.add(new BasicNameValuePair("p", "advertisement_and_media"));
    postParameters.add(new BasicNameValuePair("q", "Select Industry"));
    postParameters.add(new BasicNameValuePair("r", "Select Industry"));
    
here there are three name value pairs,namely p,q,r.These are the keys to which the value is received on the server.So whatever you send with keys "p","q","r" the data will be received in the server end with those keys/value pair.

Hope i answered your question.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top