开发者

FQL - Can i get photos of my friends posted this week

开发者 https://www.devze.com 2023-03-16 05:59 出处:网络
I try to get my friend\'s photos. posted last开发者_StackOverflow week till now how i can get this using FQL ?You would need to prompt for the friends_photos extended permission.The FQL query would

I try to get my friend's photos. posted last开发者_StackOverflow week till now

how i can get this using FQL ?


You would need to prompt for the friends_photos extended permission. The FQL query would be something like:

SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified FROM photo WHERE aid IN 
   (SELECT aid FROM album WHERE owner IN 
      (SELECT uid2 FROM friend WHERE uid1=me()) 
   ) 
AND created > One_week_ago_in_unix_time ORDER BY created DESC

Here is a full example:

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

  function getPhotos() {  
    FB.login(function(response) {
      if (response.session && response.perms) {
        var oneWeekAgo = Math.round((new Date().setDate(new Date().getDate()-7)) / 1000);
        FB.api(
          {
            method: 'fql.query',
            query: 'SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())) AND created > ' + oneWeekAgo + ' ORDER BY created DESC LIMIT 20'
          },
          function(response) {
            alert('Photos: ' + JSON.stringify(response));
          }
        );
      }
    } , {perms:'friends_photos'}); 
}
</script>
</body>
</html>
0

精彩评论

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