Roger Travis
Roger Travis

Reputation: 8548

how to get user photos from facebook?

Here's my code so far:

/// after login
Bundle params1 = new Bundle();
params1.putString("fields", "id, name, link");
mAsyncRunner.request("me/albums", params1, new AlbumsRequestListener());
...
public class AlbumsRequestListener extends BaseRequestListener {
    @Override
    public void onComplete(String response, Object state) {
        Log.e("PHOTOS",response);
    }   
}

and it returns

12-24 18:20:16.738: ERROR/PHOTOS(8170): {"data":[{"id":"301187506586589","name":"photos","link":"http://www.facebook.com/album.php?fbid=301187506586589&id=100000860254064&aid=65054","created_time":"2011-12-24T16:00:09+0000"},{"id":"299723973399609","name":"Wall Photos","link":"http://www.facebook.com/album.php?fbid=299723973399609&id=100000860254064&aid=64756","created_time":"2011-12-21T22:16:53+0000"},{"id":"299722003399806","name":"Profile Pictures","link":"http://www.facebook.com/album.php?fbid=299722003399806&id=100000860254064&aid=64755","created_time":"2011-12-21T22:12:39+0000"}],"paging":{"previous":"https://graph.facebook.com/me/albums?access_token=AAAELP9dblyEBAHgW3q8jkepd16GRnD9iDoGW0rhPYH6LxVa13ccQH6yV9sWyo8k5FBA7m15TnzlyXyIasbltJZC422ox7W34t1drDiQZDZD&format=json&fields=id,+name,+link&limit=25&since=1324742409&__paging_token=301187506586589&__previous=1","next":"https://graph.facebook.com/me/albums?access_token=AAAELP9dblyEBAHgW3q8jkepd16GRnD9iDoGW0rhPYH6LxVa13ccQH6yV9sWyo8k5FBA7m15TnzlyXyIasbltJZC422ox7W34t1drDiQZDZD&format=json&fields=id,+name,+link&limit=25&until=1324505559&__paging_token=299722003399806"}}

Now the question is - how to I get direct links to photos out of this? How do I make a request to get a photo or... well, any ideas?

Thanks!

Upvotes: 0

Views: 569

Answers (1)

J1and1
J1and1

Reputation: 920

You should use JSONArray to get out links and other stuff

JSONArray jArray = new JSONArray(result);
                for(int i=0;i<jArray.length();i++){
                            JSONObject json_data = jArray.getJSONObject(i);
                        Log.i("log_tag"," "+json_data.getString("link"));

                }

Good luck:)

Upvotes: 1

Related Questions