Welcome Guest, Not a member yet? Register   Sign In
codeigniter & DefaultHttpClient (java/Android)
#1

[eluser]Unknown[/eluser]
I am creating an android app requests info from my codeigniter based server. When the request is to just the url (www.example.com), it works fine and my app recieves whatever information is output to the browser. When i request something that more complicated (www.example.com/controller/function/variable/) I get the following error thrown from (java/Android) DefaultHttpCleint();.

"org.apache.http.client.ClientProtocolException"

the codeigniter url works well with a regular browser and even in the webView browser.

here is relevant java code
Code:
HttpClient client=new DefaultHttpClient();
        HttpGet getMethod = new HttpGet("http://**.********.com/locations/update/1/1/1/1");
        ResponseHandler<String> responseHandler=new BasicResponseHandler();
        String response;
        try {
            response = client.execute(getMethod, responseHandler);
            showNotification(response);
        } catch (ClientProtocolException e) {
            showNotification(e.toString());
            editor.putString("error", e.toString());
            editor.commit();
        } catch (IOException e) {
            showNotification(e.toString());
            editor.putString("error", e.toString());
            editor.commit();
        }
and here is the relevant php code
Code:
public function update($accessKey, $fbid, $lat=0, $long=0){
            //$me = $this->facebook->api('/me');
        
            if(!$this->locations_model->checkAccess($fbid, $accessKey))
                die("Error: access key failed");
        
        if($this->locations_model->update($fbid, $lat, $long))
            //$data['data'][0] = "location updated";
            $data['data'][0] = $this->locations_model->FriendCount($fbid)." Friends Nearby";
        else
            $data['data'][0] = "Error: location not updated ";
        
        $this->load->view('output', $data);        
    }
also i got this out of my apache error log
Code:
24.205.233.149 - - [10/May/2011:19:19:06 -0700] "GET /locations/update HTTP/1.1" 302 - "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
#2

[eluser]Unknown[/eluser]
Sorry for wasting your time, turns out DefaultHttpClient(); doesnt support cookies, and because of that i had sent myself into an endless redirect loop(cause im a dumbass). If you want you guys can delete this, or keep it for reference.
#3

[eluser]Atharva[/eluser]
[quote author="Terrortrain" date="1305101446"]Sorry for wasting your time, turns out DefaultHttpClient(); doesnt support cookies, and because of that i had sent myself into an endless redirect loop(cause im a dumbass). If you want you guys can delete this, or keep it for reference.[/quote]

It happens...stop scolding yourself Smile




Theme © iAndrew 2016 - Forum software by © MyBB