Facebook API page targeting

I am trying to bind wall posts to my fans page using the PHP PHP SDK.

The following snippet successfully sends a message to my wall, but location targeting fails.

I am new to programming and I have done my best to follow the documentation here , but this is quite rare - I'm not sure my syntax is correct.

Any help would be greatly appreciated.

//compiling the geotargeting parameters $geoTarget = "{'cities':'Richmond,VA','regions':'Virginia','countries':'US'}"; //my arguments $args = array( 'access_token' => $page_access_token, 'message' => "this is my message", 'targeting' => $geoTarget ); //posts the message $facebook->api("/$page_id/feed","post",$args); 
+4
source share
2 answers

The field is confidential in the Post table.

The description field may contain comma-separated lists of the actual country, city, and language if pages are targeted by location / language.

http://developers.facebook.com/docs/reference/api/post/

+2
source

To make it easier, you need a bit http://developers.facebook.com/docs/reference/api/page/#targeting

this will provide information on how to target your regions. http://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

What you need to complete the targeting in the question:

The country bit was right. The Virginia region code is 51 (which you can find by doing _ "> https://graph.facebook.com/search?q=vi&type=adregion&match_country_code=true&country_list=US&access_token=_ search) Richmond's city ID is 2538983 (which you can find by searching _ "> https://graph.facebook.com/search?q=richmon&type=adcity&limit=150&access_token=_)

therefore the geo-target will be

 $geoTarget = "{'cities':[2538983],'regions':[51],'countries':'US'}"; 
+2
source

All Articles