Search code examples
javascriptfacebookfacebook-graph-apifacebook-javascript-sdkfacebook-like

facebook number of page views using facebook graph api


I'm using this url for facebook graph api to get page views, and get the following in return:

{
    "data": [],
    "paging": {
        "previous": "https://graph.facebook.com/v2.3/1570694813193723/insights/page_views/lifetime?debug=all&pretty=0&suppress_http_code=1&since=1428476277&until=1428735477",
        "next": "https://graph.facebook.com/v2.3/1570694813193723/insights/page_views/lifetime?debug=all&pretty=0&suppress_http_code=1&since=1428994677&until=1429253877"
    }
}

in some queries date time error that must be unix or date time format. I can share you my access token. I urgently need number of page views and also tell me since and until format


Solution

  •     function p_view()
                {
                    //data:Array[10],
                    FB.api("/144765045682596/insights/page_views?period=day&since=1427846400&until=1429142400", function (response) {
                        for (var i = 0; i < response.data.length; i++)
                        {
                            var thread = response.data[i].values;
                            var s=13;
                            //if (thread.values[13] == thread.values[i])
                            //{
                            var tm = thread[s].end_time;
                            var th = thread[s].value;
                            document.getElementById('datev').innerHTML = tm;
                            document.getElementById('viewers').innerHTML = th;
                            //    var values = thread.values;
                            //    //var comment = thread.
                            //}
                        }
                    });
                        }