Geotargeting Page Posts with the Facebook API

倖福魔咒の 提交于 2019-12-19 03:35:55

问题


I'm trying to geotarget wall posts to my fan page using the Facebook PHP SDK.

The following snippet successfully posts a message to my wall, but the geotargeting isn't taking.

I'm new to programming and I've done my best to follow the documentation here but it's pretty sparse -- I'm not confident that my syntax is correct.

Any help would be very much 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);

回答1:


The field is privacy in the Post table

The description field may contain a comma-separated lists of valid country, city and language if a Page's post targeting by location/language is specified.

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




回答2:


To make this easier this is the bit you need http://developers.facebook.com/docs/reference/api/page/#targeting

this will give the info on how to target regions too. http://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

What you need to complete the targeting in the question would be:

The countries bit was right. Virginia's region code is 51 (which you can find by searching _">https://graph.facebook.com/search?q=vi&type=adregion&match_country_code=true&country_list=US&access_token=_) 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=_)

so the geotarget would be

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


来源:https://stackoverflow.com/questions/7893981/geotargeting-page-posts-with-the-facebook-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!