Facebook profile picture request i.e. “http://graph.facebook.com/me/picture”

When I do a request for a profile picture, mine in this case I receive some kind of encoded string in my HttpResponseHandler. The code below is the request for my profile picture.

private static AsyncHttpClient client = new AsyncHttpClient();

client.get("http://graph.facebook.com/1206433/picture",  fbPictureHandler);

The code below is my handler to retrieve a response. I get the response as a string, but I am not sure what to do with this response object. I have tried converting to a byte array and writing to "file.jpg" this hasnt worked. My main question is what do I do with this response object?

private static AsyncHttpResponseHandler fbPictureHandler = new AsyncHttpResponseHandler ()        
public void onStart() {
Log.d(TAG,"started picture handler");
public void onSuccess(String response) {
        //Not sure what to do here, have been unable to do anything with this Byte   //array
    byte[] imageBackground = response.getBytes();

    public void onFailure(Throwable error) {
        Log.d(TAG, "unable to retrieve picture");
    public void onFinish() {
        Log.d(TAG,"Finished picture handler");

This is the PrintString of the response object

11-29 19:42:12.640: D/Yatter Facebook(3551): ÿØÿà��JFIF������������ÿþ��;CREATOR: gd-jpeg     v1.0 (using IJG JPEG v62), quality = 95

ANy help is greatly appreciated and hopefully this can help others.

Thank you,


Use the following request instead of the one that you are issuing


This will return a JSON string to you in the following format which contains the original path to the profile image.

   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/260615_1206433_140418666_q.jpg"

Parse this string to get the path of "picture" and use it in your code to get the picture.

Here is a sample request example

NOTE : http://profile.ak.fbcdn.net/hprofile-ak-snc4/260615_1206433_140418666_q.jpg is obtained by parsing the JSON string in the first step.

WebRequest request = WebRequest.Create("http://profile.ak.fbcdn.net/hprofile-ak-snc4/260615_1206433_140418666_q.jpg");
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
pictureBox1.Image = Image.FromStream(stream);

This will load the image to a picture box in a windows form application.

If you need anymore help let me know.

Need Your Help

python mysqldb update where variable where in list

python mysql

I'm trying to update a field based on a variable where in list...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.