开发者

Facebook FQL / Graph - Get all current pokes

开发者 https://www.devze.com 2023-03-15 17:42 出处:网络
How can I get my curr开发者_JAVA技巧ent pokes (and pokes back)? Normaly they must be in the table \"notification\" ... I am confused.

How can I get my curr开发者_JAVA技巧ent pokes (and pokes back)?

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

Hope someone can help me.


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.",
  }
}


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.


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..."
0

精彩评论

暂无评论...
验证码 换一张
取 消