我正在关注Facebook Hosted Objects
的本地化指南我的bash脚本是:
OBJECTID=$(curl -X POST \
-F 'object={"locale":"es_ES",
"title":"mi objeto",
"description":"mi descripción",
"data": { "obj_extra":"mi información" } }' \
"https://graph.facebook.com/$APPID/objects/$APPNAMESPACE:$OBJTYPE?access_token=$APPID|$APPSECRET")
OBJECTID=${OBJECTID//[!0-9]/}
echo ID = $OBJECTID
curl -X POST \
-F 'object={"locale":"en_US",
"title":"my english object",
"description":"my english description"}' \
"https://graph.facebook.com/$OBJECTID?access_token=$APPID|$APPSECRET"
echo Spanish:
curl -X GET "https://graph.facebook.com/$OBJECTID?access_token=$APPID|$APPSECRET&locale=es_ES"
echo English:
curl -X GET "https://graph.facebook.com/$OBJECTID?access_token=$APPID|$APPSECRET&locale=en_US"
我的输出是:
ID = 270580863098812
{"type":"barnstormerdev:mobile_item","title":"my english object","locale":{"locale":"en_us"},"description":"my english description","updated_time":"2014-02-28T21:12:45+0000","id":"270580863098812","application":{"id":"239752792848708","name":"BarnStormerDev","url":"http:\/\/www.facebook.com\/apps\/application.php?id=239752792848708"}}
Spanish:
{"id":"270580863098812","type":"barnstormerdev:mobile_item","title":"my english object","locale":{"locale":"en_us"},"description":"my english description","updated_time":"2014-02-28T21:12:45+0000","created_time":"2014-02-28T21:12:45+0000","application":{"id":"239752792848708","name":"BarnStormerDev","url":"http:\/\/www.facebook.com\/apps\/application.php?id=239752792848708"},"is_scraped":false}
English:
{"id":"270580863098812","type":"barnstormerdev:mobile_item","title":"my english object","locale":{"locale":"en_us"},"description":"my english description","updated_time":"2014-02-28T21:12:45+0000","created_time":"2014-02-28T21:12:45+0000","application":{"id":"239752792848708","name":"BarnStormerDev","url":"http:\/\/www.facebook.com\/apps\/application.php?id=239752792848708"},"is_scraped":false}
这两个都不正确,因为两者都是英语。我做错了什么?
答案 0 :(得分:1)
我只想确认您的发现并报告我测试的内容:
a)我尝试了各种 locale 值,例如大写 vs 小写:
object={"locale":"en_US",
object={"locale":"es_ES",
和
object={"locale":"en_us",
object={"locale":"en_es",
通过POST创建对象时。
b)我试过
&locale=us_US
&locale=es_ES
和
&locale=us_us
&locale=es_es
通过GET获取对象时。
我还测试了元版本:
&og:locale=us_US
&og:locale=es_ES
和
&og:locale=us_us
&og:locale=es_es
没有任何运气。
c)我试图在西班牙语对象之前创建英语对象,反之亦然,但只有最后更新的对象是通过GET获取的,无论语言环境的值是什么参数是。
d)我尝试创建与您完全一样的对象,以及在示例中完成的方式。
所以我建议你把这个报告给Facebook作为错误或错误的文档。
<强>更新强>
请查看这个类似的问题,答案是:
facebook localization of hosted objects
看起来它已经是reported to Facebook and confirmed since January 23rd 2014!了。
本来可以为我们节省大量的测试时间; - )
答案 1 :(得分:0)
我个人从未使用自定义本地化的OpenGraph对象,但我找到了文档
最后一个链接指出:
对象属性值可以存储为多种语言。要做 确保您的对象被多种语言删除,请务必这样做 以下任一项:
- 调用Graph API以使用locale参数更新对象URL。
- 指定og:locale:alternate meta标签的数组以定义哪个 你支持的语言环境。
段落中还有一些细节。您是否尝试在对象上使用OpenGraph调试器?
在你的输出中,我看到is_scraped是假的。您是否尝试将参数&amp; scrape = true 添加到此类请求中(如第二个最后一个链接所述):
OBJECTID=$(curl -X POST \
-F 'object={"locale":"es_ES",
"title":"mi objeto",
"description":"mi descripción",
"data": { "obj_extra":"mi información" } }' \
"https://graph.facebook.com/$APPID/objects/$APPNAMESPACE:$OBJTYPE?scrape=true&access_token=$APPID|$APPSECRET")