开发者

Photos in the Facebook album not showing

I am using Facebook connect and JS client library to retrieve my photos in my Facebook account.

Below is my code:

<div id="photos_pics"></div>
<script type="text/javascript">
    var widget_div = document.getElementById("photos_pics");
    FB.ensureInit(function () {
        FB.Facebook.get_sessionState().waitUntilReady(function() {
            FB.Facebook.apiClient.photos_get('12345678', null, null, function(photos,e) {
                var markup = "";
                for (var i = 0; i < photos.length; i++) {
                    var photo = photos[i];
                    var photo_pid = photo.pid;
                    markup += '<fb:photo size="small" pid="'+photo_pid+'"></fb:photo>';
           开发者_如何学Python     }
                widget_div.innerHTML = markup;
                FB.XFBML.Host.parseDomElement(widget_div);
            });
        });
    });
</script>

The below method retrieves the photos:

FB.Facebook.apiClient.photos_get(uid, aid, null, result)

When I only specify uid which is my Facebook id, it works and photos (not in any albums) are returned. But when I specify one of my photo albums in aid, no results returned.

Anyone know what is the error I made? Thanks in advance.


I have recently been having a significant number of problems with retrieving photos from facebook lately as well. Almost always it is revolving around a recent change they have made to pid's. When viewing a photo in facebook you will see two query variables in your url pid and aid.

http://www.facebook.com/home.php#/photo.php?pid=9513212&id=672915455

although this is deceiving because the recent change that facebook made to pid's is that they are actually in the form id_pid so if I were to include the above photo in an fb photo tag it would look like the following

<fb:photo size="small" pid="672915455_9513212"></fb:photo>

Although I am having lots of problem with this because in more than one place facebook is being inconsistent with which form of pid it will return or is looking for.

So my first suggestion is to see which style pid you are receiving and which ones you are trying to use. This is most likely your current problem.

Your next problem is going to be the fact that there is a current bug in the xfbml version of the fb:photo tag. Currently the tag errors out when parsing the new style tags that have an "_" in them. To get around this we simply made a query for the direct url that facebook uses for the image, and display it using a simple html img tag

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜