簡體   English   中英

FB.api問題

[英]Problems with FB.api

我編寫了以下代碼,但是由於某些原因, 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);
    }
});

什么幫助或建議嗎?

您需要指定訪問令牌,我遇到了同樣的問題..我只添加了訪問令牌並解決了問題..

在這里看看: 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);
        }
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM