Feed对话框不可用?

时间:2017-05-20 15:38:17

标签: javascript html facebook facebook-graph-api

输入电话号码和密码后出现以下错误

  

很抱歉,此功能目前无法使用:发生错误   处理此请求。请稍后再试。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <title>Document</title>
    <script>
        $(function(){
            $(".facebookLink").on("click", function(){
                // $.ajax({
                //     method
                // })
                var reviewId = $(this).data("id");
                console.log("ReviewID", reviewId)
                var appId = "{myID}" // I use real appId
                var redirectUri = "http://localhost:3000/reviewfor/x.com"
                var description = "this is my description";
                var link = "http://localhost:3000/reviewfor/x.com"
                this.href= `https://www.facebook.com/dialog/feed?app_id=${appId}&redirect_uri=${redirectUri}&description=${description}&link=${link}`
            })
        })
    </script>
</head>
<body>
    <% reviews.forEach(review => { %>
        <div>
        <span>review text : </span> <%= review.reviewText %> <span> ReviewID : <a href = "/review/<%=review._id%>"><%=review._id%></a> </span>
        <a class = "facebookLink" data-id ="<%= review._id%>">share to Facebook</a>
        </div>
    <% }) %>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我认为最好的方法是如果你正确实施Facebook的SDK。

https://developers.facebook.com/docs/javascript/reference/FB.ui

我相信你希望Share Dialog能够出现在你的情况下

https://developers.facebook.com/docs/sharing/reference/share-dialog

如果为true,则实现看起来像这样

var link = "http://localhost:3000/reviewfor/x.com"
FB.ui({
    method: 'share',
    href: yourLink,
}, function(response){});

为了能够正确调用此API,请务必使用FB.init

初始化SDK

https://developers.facebook.com/docs/javascript/reference/FB.init/v2.9