Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Geo-targeting parameters being ignored by Facebook when posting through Koala #221

samdec opened this Issue Jun 11, 2012 · 7 comments


None yet
4 participants

samdec commented Jun 11, 2012

When using Koala to create feed posts Facebook ignores the provided geo-targeting parameters. When using the FB Graph API explorer with the same parameters the post appears properly geo-targeted.

Here's example code that will reproduce the issue:

require 'koala'

page_oauth_token = "your_oauth_token"

graph_client = Koala::Facebook::API.new(page_oauth_token)

params = {
"message" => "Hello Toronto!",
"targeting" => {
"countries" => "CA",
"cities" => "296875"

fb_id = your_page_id

graph_client.put_object(fb_id, "feed", params)

The message appears on Facebook, but without any geo-targeting. You can use the Graph API explorer to pass in the same parameters (as JSON though) and use the same OAuth token to create a post that is geo-targeted.

samdec commented Jun 13, 2012

I was able to resolve this by converting the targeting hash into JSON before posting through Koala.

Add these lines to the code and it works:

require 'yajl'

params["targeting"] = Yajl::Encoder.encode(params["targeting"])

We've actually run into a similar problem with adding custom actions (like a Share button) to FB page posts. We have to encode the actions parameter as JSON and put it inside an array.


bnorton commented Jun 16, 2012

I have found that the same is true as well


arsduo commented Jul 22, 2012

Sigh. I've seen this in several places, and I'm not sure there's anything we can do about this in Koala -- the API is deliberately ignorant of the details of the Facebook API, and there's no clear documentation of the geotargeting API that I can find, let alone all the places where Facebook requires you to JSON-encode parameters.

I would actually highly recommend filing a Facebook bug to ask that (a) this be properly documented and (b) they remove the requirement to JSON-encode the targetting string separately from the rest of the body (e.g. forcing us to double-encode it). I think that's all we can do. If you post the bug here I'd be happy to comment on it.

@arsduo arsduo closed this Jul 22, 2012


bnorton commented Jul 22, 2012

We do this for custom share actions

  :actions => [{:name => 'Share', :link => share_url}].to_json

arsduo commented Sep 5, 2012

I forwarded this on to a friend at Facebook a whole back, who just told me he's filed an internal ticket (and acknowledged it's absurd). It looks like their system can't handle non-encoded nested params (this is also an issue with app restrictions).

I'm going to add a section in the Koala documentation for this -- let me know if you find any other examples.

@arsduo arsduo reopened this Sep 5, 2012

CTres commented Apr 29, 2016

Hey @arsduo, was there ever a solution to this? I am trying to geo target a wall post for a client's fb page and the targeting is still just ignored.


arsduo commented Feb 17, 2017

@CTres apologies for the late response. Was it being ignored even if you JSON-encoded it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment