使用 Facebook API 对页面帖子进行地理定位
我正在尝试使用 Facebook PHP SDK 将墙贴地理定位到我的粉丝页面。
以下代码片段成功地将消息发布到我的墙上,但地理定位未进行。
我是编程新手,我已尽力遵循此处 但它非常稀疏——我不确定我的语法是否正确。
任何帮助将非常感激。
//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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该字段是“帖子”表中的隐私字段
。如果指定了按位置/语言定位页面的帖子,则说明字段可能包含有效国家/地区、城市和语言的逗号分隔列表。
http://developers.facebook.com/docs/reference/api/post/
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/
为了使这更容易,这就是您需要的http://developers.facebook。 com/docs/reference/api/page/#targeting
这也将提供有关如何定位区域的信息。
http://developers.facebook.com/docs/reference/ ads-api/get-autocomplete-data/
完成问题中的定位所需的内容是:
国家/地区位是正确的。
弗吉尼亚州的区域代码是 51(您可以通过搜索 _">https://graph.facebook.com/search?q=vi&type=adregion&match_country_code=true&country_list=US&access_token=_ 找到该代码)
里士满的城市 ID 是 2538983(您可以通过搜索 _">https://graph.facebook.com/search?q=richmon&type=adcity&limit=150&access_token=_ 找到),
因此地理目标为
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