fb.api或fb.ui如何上传照片

时间:2013-07-20 13:38:31

标签: javascript facebook upload

我正在使用Javascript,我的应用程序使用FB.ui和FB.api发布到Facebook 最近,我收到了一封邮件,内容如下:

  

看起来您的应用,(...)可能会发布预先填好的照片   字幕。如果是这种情况,您将要删除任何默认照片   未来几天内的字幕,以避免限制。

     

提醒一下,Facebook平台政策下不允许这样做   因为我们希望应用程序发布的故事代表用户   语音。您可以在以下位置详细了解此政策:   https://developers.facebook.com/policy/#integration

我使用的功能如下,现在,经过这么多的测试,我真的无法理解哪个功能是问题。 我怀疑函数upload_foto可能是问题,但我不确定,如果我不能使用javascript FB.api上传照片那么我该怎么做? 知道如何解决这个问题吗?

function postToWall(to_user_id, title1, url_to_picture, link_to_open) {
        var control = document.getElementById("my_silverlight");
        //this will publish a story to the specified user or page (post owner is the user not the page)
        FB.ui({ method: 'feed',
            name: title1,
            display: 'iframe',
            link: link_to_open,
            description: 'Some description',
            caption: 'Some caption',
            picture: url_to_picture,
            type: 'photo',
            to: to_user_id
        }, function (response) {
            if (response && response.post_id) {
                control.content.PageName.update_post("success");
            } else {
                control.content.PageName.update_post("error");
            } 
        });
    }

function postToPage(to_user_id, title1, url_to_picture, link_to_open) {
    var control = document.getElementById("my_silverlight");
    //this will publish a story to page if the user is the page's administrator (post owner will be the page itself)
    FB.ui({
        method: 'feed',
        name: title1,
        display: 'iframe',
        link: link_to_open,
        description: 'Some description',
        caption: 'Some caption',
        picture: url_to_picture,
        type: 'photo',
        to: to_user_id,
        from: to_user_id
    }, function (response) {
        if (response && !response.error) {
            control.content.PageName.update_post("success");
        } else {
            control.content.PageName.update_post("error");
        }
    });
}

function postToGroup_Event(to_profile_id, title1, mes, url_to_picture, link_to_open) {
    var control = document.getElementById("my_silverlight");
    //this will publish a story to a group or an event as the curent user 
    FB.api("/" + to_profile_id + "/feed", 'post', { name: title1, link: link_to_open, description: 'Some description', caption: 'Some caption', picture: url_to_picture, message: mes }, function (response) {
        if (response && !response.error) {
            control.content.PageName.update_post("success");
        } else {
            control.content.PageName.update_post("error");
        }
    });
}

function upload_foto(from, to_profile_id, url_to_foto, mess, own_wall) {
    var control = document.getElementById("my_silverlight");
    //this will publish a foto with a message to a profile
    FB.api(to_profile_id + '?fields=access_token', function (response) {
        if (response && !response.error) {
            FB.api(to_profile_id + '/photos', 'post', { from: from, url: url_to_foto, message: mess, access_token: response.access_token }, function (response) {
                if (response && !response.error) {
                    control.content.PageName.update_post("success", response.post_id);
                } else {
                    control.content.PageName.update_post("error", "");
                }
            });
        } else {
            control.content.PageName.update_post("error", "");
        }
    }, { scope: '' });
}

1 个答案:

答案 0 :(得分:1)

功能“upload_foto”是问题所在。

根据Facebook政策,发送预填标题(消息)违反了Facebook平台政策的第IV.2节。此政策禁止应用预先填写代表用户发布的任何照片的标题,除非用户在工作流程中较早创建了内容。

应用无法设置“消息”。这意味着您需要让用户写入消息或不包含任何消息。