Facebook FQL / Graph - Get all current pokes

2019-05-28 22:02发布

How can I get my current pokes (and pokes back)?

Normaly they must be in the table "notification" ... I am confused.

Hope someone can help me.

3条回答
来,给爷笑一个
2楼-- · 2019-05-28 22:42

Here are the Facebook REST docs for how to get notifications, which should include Pokes.

"If you are building an application that notifies users of new messages/pokes/shares, we encourage you to use the following logic..."
查看更多
SAY GOODBYE
3楼-- · 2019-05-28 22:43

Here is a working example that prompts for read_mailbox permission and uses /me/pokes to retrieve a users pokes. This can be done in any server side language too using the same logic.

Get Pokes:

<!DOCTYPE html>
<html>
<body>
<div id="fb-root"></div>
<a href="#" onclick="getPokes();return false;">Get Pokes</a>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({ appId  : '**yourAppID', status : true, cookie : true, xfbml  : true });

  function getPokes() {  
    FB.login(function(response) {
      if (response.session && response.perms) {
        FB.api('/me/pokes',  function(response) {
            for(var i=0; i < response.data.length; i++) {
              alert(response.data[i].from.name + " poked you.");
            }
          }
        );
      }
    } , {perms:'read_mailbox'}); 
}
</script>
</body>
</html>

Poke back: To poke a user back, you would issue an HTTP Post to /userid/pokes but you need to get whitelisted by Facebook. Otherwise you will get this response:

{
  error: {
    type: "OAuthException",
    message: "(#3) Application does not have the capability to make this API call.",
  }
}
查看更多
来,给爷笑一个
4楼-- · 2019-05-28 22:50

Using the graph API, using the right access token of course (you need the "read_mailbox" permission"), access https://graph.facebook.com/me/pokes

Replace "me" in the graph API for a Facebook UID you have permission to access to.

查看更多
登录 后发表回答