显示当前的脸书通知


Displaying current Facebook notifications

我试图在网页上显示用户的Facebook通知,就像它在Facebook本身中的显示方式一样。但是,我坚持如何准确地对Facebook API进行此查询,然后更新网页。

我创建了一个查询,希望它能返回我需要的内容:

SELECT notification_id, sender_id, title_html, body_html, href
FROM notification
WHERE recipient_id=<uid>
AND is_unread = 1
AND is_hidden = 0

我被困住了,找不到关于如何使用 JavaScript 发送此查询的任何内容?我是否必须向返回响应或其他内容的单独 PHP 页面发出 AJAX 请求?

试试这个:

FB.api({
    method: 'fql.query',
    query: 'SELECT notification_id, sender_id, title_html, body_html, href'
        + ' FROM notification'
        + ' WHERE recipient_id=' + uid
        + ' AND is_unread = 1'
        + ' AND is_hidden = 0'
}, function(response){
    console.log(response);
});