如何使用JavaScript SDK在位置附加到Facebook [英] How to post to Facebook with location attached using JavaScript SDK
问题描述
我想使用Javascript SDK从Phonegap移动应用程序发布到用户的Facebook墙。我可以从我的应用程序发布消息到用户的墙。我想附加一个位置的帖子,使它看起来像一个签入。
I am trying to post to a user's Facebook wall using Javascript SDK from a Phonegap mobile app. I am able to post a message to the user's wall from my app. I want to attach a location to the post so that it looks like a checkin. Facebook checkin was working fine, but since it was deprecated, I want to use Post as suggested by Facebook.
以下是我的代码:
FB.api('/me/feed', 'post', {
name: 'SomeName',
message: 'SomeMessage',
place: {
'id': pageId,
'name': name,
'location': {
'latitude': latitude,
'longitude': longitude
}
}
},
function (response) {
if(response){
alert("Post was published!");
}
else {
alert("Post was not published. Try again.")
}
});
地方标记需要具有纬度和经度的ID,名称和位置,以上。我收到警告消息,表明帖子已发布!,但它不会发布到用户的墙上。如果我拿出地方字段,它工作正常。
The place tag needs the id, name and location with the latitude and longitude, so I provided them as above. I get the alert message saying the Post was published!, but it isn't posted to the user's wall. If I take out the place field, it works fine.
提前感谢。
推荐答案
仅为位置ID设置位置。这个例子刚刚在我的应用程序搜索解决方案:
Set place only for location ID. This example just worked as I searched solution for my application:
FB.api('/me/feed', 'post', {
name: 'SomeName',
message: 'SomeMessage',
place: '106039436102339' // ID for Tallinn, Estonia
}, function (response) {});
这篇关于如何使用JavaScript SDK在位置附加到Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!