简体   繁体   English

如何使用JavaScript SDK附加位置附加到Facebook

[英]How to post to Facebook with location attached using JavaScript SDK

I am trying to post to a user's Facebook wall using Javascript SDK from a Phonegap mobile app. 我正在尝试使用Phonegap移动应用程序中的Javascript SDK将其发布到用户的Facebook墙。 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. Facebook签入工作正常,但是由于不建议使用,我想按照Facebook的建议使用Post。

Below is my code: 下面是我的代码:

    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.")
    }
    }); 

The place tag needs the id, name and location with the latitude and longitude, so I provided them as above. 位置标签需要带有经度和纬度的ID,名称和位置,因此我如上所述提供了它们。 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. 如果我删除了位置字段,则效果很好。

Thanks in advance. 提前致谢。

Set place only for location ID. 设置地点仅用于位置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) {}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM