Picasso library stopped working today with facebook graph picture links
Asked Answered
M

3

14

In my app i use Picasso library to load images from urls. It is a nicely working easily importable and usable library, and just do the thing i need.

However, today it stopped working, and not while developping it is stopped working on a compiled apk.

So after i searched and searched for the reason i just found this buggy thing:

I use facebook graph urls to load profile pictures.

Here is one like: profile pictre,

the link is actually "http://graph.facebook.com/1464090949/picture?type=large"

But it is redirecting to: https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/572518_1464090949_1222130273_n.jpg

Of course, both of url calls working in a browser, and you can see the profile picture.

However when i test both links with Picasso:

    ImageView iv = (ImageView)findViewById(R.id.imageView1);

    //Url1 NOT working, loads nothing.
    String url1 = "http://graph.facebook.com/1464090949/picture?type=large";

    //Url2 is the same as URL1, i just copied it from a browser, and this is working
    String url2 = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/572518_1464090949_1222130273_n.jpg";


    Picasso.with(this).load(url2).into(iv);

So the conclusion is, facebook maybe changed something and from now on Picasso cannot load images from graph.

Anybody can suggest me something to make this work? Of course i can try different libraries but if there is an other way i would be really happy.

Marketa answered 26/3, 2014 at 22:48 Comment(2)
This has happened to us too. Everything was working fine until later yesterday. We are not using Picasso, just Facebook SDK. Either way, we're simply loading the picture form a URL so it's definitely not a library problem. Something seems has changed on Facebook side. They always used to redirect though to that fbcdn. Still looking for a solution. keeps us posted. thanksHumeral
Well its good to see its not just for me, altough i feel for you guys. I'll edit when i figure out something, thanks for your comment!Marketa
M
43

Workaround1:

Change to https from http.

Working: https://graph.facebook.com/1464090949/picture?type=large

Not Working: http://graph.facebook.com/1464090949/picture?type=large

Workaround2:

Found soulution on this topic.

If you want for example: http://graph.facebook.com/1464090949/picture?type=large

This profile picture you could use:

https://graph.facebook.com/1464090949/?fields=picture.type(large)

Which returns a JSON Object:

   {
   "id": "1464090949",
   "picture": {
      "data": {
         "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/572518_1464090949_1222130273_n.jpg",
         "is_silhouette": false
      }
   }
}

And tada! There it is. url's key is the redirected url you can use to load your images.

(This will need oAuth which i didnt tested, just stick with Workaround1)

Marketa answered 27/3, 2014 at 11:6 Comment(2)
Workaround3: Use OkHttp which will follow redirects from HTTP to HTTPS.Odonto
both workarounds doesn't worked out for me :( it seens the issue happens only in android 5.1.1 Moto X. Didn't tested on others devices, but all my android 5.1.1 had this problem.Kurdish
C
5

Try this. worked for me perfectly

Dependency: compile 'com.squareup.okhttp:okhttp:2.5.0'

Picasso.Builder builder = new Picasso.Builder(mContext);
        builder.listener(new Picasso.Listener() {
            @Override
            public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                /*holder.getIvSpeakerPicture()
                        .setImageDrawable(context.getResources()
                                .getDrawable("your drawable id"));*/
            }
        });
        builder.downloader(new OkHttpDownloader(mContext));
        builder.build().load(image).into(viewHolder.image);
Closeknit answered 19/3, 2017 at 14:51 Comment(2)
This helped me :)Intertexture
In my case I had to use a modified OkHttpDownloader to get it work (compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'). shown in this post: https://mcmap.net/q/225206/-noclassdeffounderror-for-okhttpclientProtector
P
0

In case you're using Amazon AWS CloudFront just like me, you can visit this page for detailed instructions from Amazon on how to set up your URL forwarding.

At the least, for Picasso to work with your redirected URLs, your URLs must support https. That is. https://yourdomain.com should redirect to https://yourAWScloudfrontdomain.net

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html#CNAMEsAndHTTPS

Phallic answered 29/8, 2015 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.