Question

Im trying to do a FQL query in my android application with AQuery. In the first FQL Query i got the JSON just normal, but when i scroll my list to get more posts (calling another method using created_time comparisons ) i got a network error e aquery and the JSON is null.

If i test the url in my browser, it runs correctly and returns the json data, but when i run with android, i get this network error and json comes null.

Anyone can give me a help?

This is the method called when i scroll:

public void callJsonNext(){

    progress_bottom.setVisibility(View.VISIBLE);

    final AQuery aq = new AQuery(getActivity());

    String URL = URL_postagens_passadas + created_time_olds + "limit%2010&access_token=" + access_token;

    Log.d("URL_CALL_JSON_NEXT", URL);

    aq.ajax(URL, JSONObject.class, new AjaxCallback<JSONObject>() {


        @Override
        public void callback(String url, JSONObject json, AjaxStatus status) {

            Log.d("STATUS_NEXT", status.toString());

                if(json != null){

                    fillArrayWithOlderPosts(json);

                }else{      
                 Toast.makeText(aq.getContext(), "Error:" + status.getCode() + " in Json Next" + status.getError() + status.getMessage() + status.getSource(), Toast.LENGTH_LONG).show();
                 Toast.makeText(aq.getContext(), "Error:" + status.getCode() + " in Json Next" + status.getError() + status.getMessage() + status.getSource(), Toast.LENGTH_LONG).show();
                }
        }
});

}
Was it helpful?

Solution 2

I just use the code bellow, and works perfectly. :)

Facebook just allows fql requests with created_time, if you use their own request method.

public void callJsonPrevious(){

        if ((!created_time_news.equals("") && created_time_news != null)){
        progress_top_top.setVisibility(View.VISIBLE);

        String query = "select post_id, created_time, updated_time, attachment, share_count,like_info, message,likes from stream where source_id=351126731639471 and actor_id=351126731639471 and created_time >" + created_time_news;
            Bundle params = new Bundle();
            params.putString("q", query);
            params.putString("access_token", access_token);
            Session session = Session.getActiveSession();
            Request request = new Request(session,
                "/fql",                         
                params,                         
                HttpMethod.GET,                 
                new Request.Callback(){         
                    public void onCompleted(Response response) {
                        JSONObject json;
                        json = new JSONObject();
                        json = response.getGraphObject().getInnerJSONObject();
                        fillArrayWithNewPosts(json);
                    }                  
            }); 
            Request.executeBatchAsync(request); 
        }else{

            getFirstPosts();

        }
    }

OTHER TIPS

Try copy the url and paste in browrser and see whats the response.

Or use String.class as type for the second call and print out the response to debug.

Most likely something wrong with url that cause the result to be an invalid json type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top