bobolounna / restfb

Automatically exported from code.google.com/p/restfb
0 stars 0 forks source link

FacebookClient.fetchObject not working for graph reachestimate #168

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. instantiate defazkt facebook client object
2. call fetchObject with parameters 
"act_xxx/reachestimate?currency=EUR&targeting_spec={'age_min':'18','age_max':'65
','countries':['DE']}" and "String.class"
3. com.restfb.FacebookNetworkException thrown

What is the expected output? What do you see instead?
Valid Targeting in a String Object with the content received from the the graph 
explorer for the exact same call. Instead the following error message is 
thrown: com.restfb.FacebookNetworkException: A network error occurred while 
trying to communicate with Facebook: Facebook GET failed (HTTP status code 400)

What version of the product are you using? On what operating system?
1.6.9

Original issue reported on code.google.com by chex...@googlemail.com on 13 Dec 2011 at 2:35

GoogleCodeExporter commented 8 years ago
Can you include the code just so I can reliably reproduce and verify?  Thanks!

Original comment by m...@xmog.com on 13 Dec 2011 at 7:06

GoogleCodeExporter commented 8 years ago
Of course! :)

Here is the code. targeting_spec is a valid Targeting String like 
{'age_min':'18','age_max':'65','countries':['DE']}

        FacebookWebRequestor requestor = new FacebookWebRequestor();
        DefaultJsonMapper jsonMapper = new DefaultJsonMapper();

            String requestParameter = "act_"+account.getExtAccountId()+"/reachestimate?currency=EUR&targeting_spec=" + targeting_spec;

            FacebookClient fbc = new DefaultFacebookClient(accessToken, requestor, jsonMapper);
            String requestedStats = fbc.fetchObject(requestParameter, String.class);

Original comment by chex...@googlemail.com on 14 Dec 2011 at 8:09

GoogleCodeExporter commented 8 years ago
Sorry for the very late response...you should specify URL parameters like this:

fbc.fetchObject("act_"+account.getExtAccountId()+"/reachestimate", 
String.class, Parameter.with("currency", "EUR"), 
Parameter.with("targeting_spec", "..."));

Instead of hardcoding a JSON string for targeting_spec, you can pass in a Map 
or your own @Facebook-annotated class for the value of Parameter.with() and 
RestFB will automatically marshal it to JSON.

Original comment by m...@xmog.com on 12 Jan 2012 at 7:28

GoogleCodeExporter commented 8 years ago
I think this is not an issue, closing out...

Original comment by m...@xmog.com on 2 Sep 2012 at 1:57