DeveloperFahem / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

problem with getting photos for every album #265

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to runa tomcat based webapp on facebook.

I am in need of getting the photos to display on the webpage from the 
various user albums

following is the code I use
I get the albumIds allright !! but I cant get in to photos for that 
particular album. 

any help would be greatly appreciated.

FacebookXmlRestClient client =  new FacebookXmlRestClient(apiKey, 
secretKey, sessionKey);
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
xpath.setNamespaceContext(new FacebookNamespaceContext());
client.setNamespaceAware( false );
Long userId = client.users_getLoggedInUser();
Document doc = client.photos_getAlbums( userId );
NodeList album = (NodeList)xpath.evaluate( "//album", doc, 
XPathConstants.NODESET );

for(int i=0; i<album.getLength(); i++){
    Node albumNode = album.item(i);
    //out.println(xpath.evaluate( "aid/text()", albumNode ));
    Document photos = 
client.photos_get(userId,Long.parseLong(xpath.evaluate( "aid/text()", 
albumNode )));
    //out.print("what is going on!?");
    NodeList photosList = (NodeList)xpath.evaluate( "//photo", photos, 
XPathConstants.NODESET );

    for(int y=0; y<photosList.getLength(); y++){
    Node photoNode = photosList.item(y);
    out.println(xpath.evaluate( "pid/text()", photoNode));
    }
}

Original issue reported on code.google.com by nishanth...@gmail.com on 12 Nov 2009 at 6:29