0

我有一个 facebook 应用程序,用户可以在其中为他们的图像提供类似 instagram 的效果。 http://instakilo.herokuapp.com/
添加图像过滤器时,底部会出现一个下载链接,单击该链接时,将创建该编辑图像的源并将其添加到下载链接的“href”属性中,并下载图像。现在我不想下载图像,而是想将该图像发布到用户墙上并附上一些标题。

我搜索了一些教程,但他们显示通过 HTML 表单上传图片,用户从硬盘驱动器中选择图像并发布,但在这里我有该图像的来源,在 javascript 变量中。正如您在我的应用程序中的 script.js 文件中看到的那样,script.js 末尾的以下代码

function showDownload(canvas){


    downloadImage.off('click').click(function(){

        // When the download link is clicked, get the
        // DataURL of the image and set it as href:

        var url = canvas.toDataURL("image/png;base64;");
        downloadImage.attr('href', url);
        $.ajax({

                        type: "POST",
                        url: "http://instakilo.herokuapp.com/process.php",
                        data: {'data':url},
                        success: function(){alert('Posted');},
                        error:function(){alert('error');}
                    });



    }).fadeIn();
            downloadImage.css("display","inline-block");  

}

在 url 变量中存储图像源。如您所见,我尝试使用 ajax 将其发布到 process.php,但它似乎不起作用。

我怎样才能做到这一点?

4

1 回答 1

0

从 URL 使用urlme/photos端点发布照片

var params = {};
params['message'] = 'The message';;
params['url'] = url;


FB.api('/me/photos', 'post', params, function(response) {
    if (!response || response.error) {
    // an error occured
        alert(JSON.stringify(response.error));
    } else {
    // Done
        alert('Published to stream');
    }
});
于 2013-03-10T19:37:01.533 回答