Javascript FB.api的问题

Javascript FB.api的问题,javascript,facebook,facebook-graph-api,Javascript,Facebook,Facebook Graph Api,我编写了以下代码,但由于某种原因,FB.api无法工作。我可以这么说,因为javascript控制台中没有日志消息。我已经对用户进行了身份验证并获得了发布流权限。下面的代码在FB.login块中(我希望这不是问题)。我使用了jQuery,因为我已经知道如何使用它发出get请求 jQuery.ajax( { url: access, dataType: 'json', success: function (resp) { var data_item='This i

我编写了以下代码,但由于某种原因,FB.api无法工作。我可以这么说,因为javascript控制台中没有日志消息。我已经对用户进行了身份验证并获得了发布流权限。下面的代码在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);
    }
});

任何帮助或建议

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

请看这里:


当你o FB.login时,在响应中将包含访问令牌,将其存储在某个地方,并在需要使用时调用它。我这样做了,但如果你愿意,它仍然不起作用。我可以给出完整的代码
    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);
        }
    });