$request = new FacebookRequest( $session, 'GET', '/{ad-account-id}/reachestimate', array( 'targeting_spec' => '{"behaviors": [{"id":6015559470583}],"geo_locations": {"countries":["US"],"location_types": ["home"]},"age_min": 20,"age_max": 40 }' ) ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* handle the result */I tried using fetchConnection and send parameters using a map but no success.
You can use the Targeting object.
List<IDName> behaviors = new ArrayList<IDName>();
IDName behavior = new IDName();
behavior.setId("6015559470583");
behaviors.add(behavior);
TargetingGeoLocation geoLocation = new TargetingGeoLocation();
geoLocation.setCountries(Collections.singletonList("US"));
geoLocation.setLocationTypes(Collections.singletonList("home"));
Targeting targetingSpec = new Targeting();
targetingSpec.setAgeMin(20L);
targetingSpec.setAgeMax(40L);
targetingSpec.setGeoLocations(geoLocation);
targetingSpec.setBehaviors(behaviors);
In fetchConnection you simple add Parameter.with("targeting_spec", targetingSpec)
.
Everything else should work as you tried.
Hope this helps.
Norbert
JsonObject fetchObjectsResults=
facebookClient.fetchConnection("{ad-account-id}/reachestimate", JsonObject.class, Parameter.with("targeting_spec", targetingSpec));Try fetchObject
with String
as response object and provide the returning String. Perhaps we get some more information. ATM it looks like the returned JSON does not contain a data field.
Best Regards
{ "data": { "users": 21000000, "estimate_ready": true } }
Attaching a screenshot also.