Problems with FB.api

Problems with FB.api

本文关键字:api FB with Problems      更新时间:2023-09-26

我编写了以下代码,但由于某些原因,FB.api无法工作。我可以这么说是因为javascript控制台中没有日志消息。我已经对用户进行了身份验证,并获得了publish_stream权限。下面的代码在FB.login块中(我希望这不是问题)。我已经使用了jQuery,因为我已经知道如何使用它来发出get请求。

jQuery.ajax( {
    url: access,
    dataType: 'json',
    success: function (resp) { 
    var data_item='This is a successful post plz do not comment this is a test';
    FB.api('me/feed', 'post', {message: data_item}, function(response) {
    if (!response || response.error) {
        console.log('Error occured');
    } else {
        console.log('Post ID: ' + response.id);
    }
});

有什么帮助或建议吗

您需要指定acess令牌,我也遇到了同样的问题。。我只是添加了访问令牌并解决了问题。。

看看这里:http://www.friendouh.com/

    jQuery.ajax( {
        url: access,
        dataType: 'json',
        success: function (resp) { 
        var data_item='This is a successful post plz do not comment this is a test';
        FB.api('me/feed', 'post', {message: data_item,access_token: 'your_acess_token'}, function(response) {
        if (!response || response.error) {
            console.log('Error occured');
        } else {
            console.log('Post ID: ' + response.id);
        }
    });