Picasso library stopped working today with facebook graph picture links - android

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.

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)

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);

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

Related

How do I play GIF from a url using GifImageView by droids on roids?

I need to play a gif file from a URL. I am new to android and am using droids on roids library to achieve this.
I tried the following code :
gifImageView.setVisibility(View.VISIBLE);
Uri gifuri = Uri.parse(gifurl);
gifImageView.setImageURI(gifuri);
I wanted the gif to start but instead I see a blank screen/
Everything looks like it would work correctly... Make sure that the phone you're testing your app on is online, and that the URL you are requesting is an image and nothing else. Also, you could try using the Glide Library instead of Droids On Roids.

I can't load images from Graph Facebook

url: https://graph.facebook.com/100779423975829/picture?type=large;
other url with type normal: https://graph.facebook.com/100779423975829/picture?type=normal
I tried to load url with Glide, Picasso, UniversalImageLoader and decodeStream from BitmapFactory and don't have any good result and the result is the next:
UniversalImageLoader: Image can't be decoded
BitmapFactory: bitmap = null
If I open the url with Chrome pc I will automatically download the photo without opening it.
in the webview from my app, i check the redirects from this url:
https://lookaside.facebook.com/platform/profilepic/?asid=100779423975829&height=200&width=200
https://m.facebook.com/platform/profilepic/?asid=100779423975829&height=200&width=200
Anyone else is having problems loading image profiles from Facebook graphs?
Thanks!
EDIT
The bug is resolved from Facebook.
https://developers.facebook.com/bugs/261587761048160/
Finally this was a facebook bug. So the problem is fixed by themselves.
https://developers.facebook.com/bugs/261587761048160/
Yes, the redirections from http:// to https:// protocols hinders the downloading using Picasso,Glide ets. You may go ahead with following two approaches:
SimpleDraweeView from Facebook Sdk. It handles the redirection internally.
Make a graph request to fetch the re-directed url like below and use that url in picasso.
new GraphRequest(AccessToken.getCurrentAccessToken(),
"/"+fbUserId+"/picture?width="+width+"&height="+height+"&redirect=false",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
String url = response.getJSONObject().getJSONObject("data").getString("url");
loadFacebookProfilePicInImageView(url);
} catch (Exception e) {
e.printStackTrace();
}
}
}
).executeAsync();
I have the same issue. If you don't want to use the graph api for loading the public profile picture (as in my case) we both have a problem unless someone knows the solution.
I have the same problem. It seems to be a bug. I think we are best of just waiting a day or two instead of putting the effort in fixing this ourselves. See also : Facebook graph user picture won't show on mobile devices and https://developers.facebook.com/bugs/560392384345729/

displaying an image from drive in Android

I'm using Fresco library to display images in my Android app. I'd like to display some images (jpg or png) that I have set with public grants.
When I was doing quick tests, I just took any image from internet to set a URL, but when using the real ones that I need to use, I have the following url https://drive.google.com/uc?export=view&id=<>, but as it is a redirect and, once redirected, new url is not the image itself, Fresco is unable to display it.
I have tried Picasso as an alternative library, but with out any success.
I have also tried the download url for both libraries (https://drive.google.com/uc?export=download&id=<>). But no result.
Anybody knows how could it be possible to get this images? Or the only solution is to download it (using the second url) processing the object received store a bitmap of it and displaying it?
For downloading it, what should i use and how? retrofit?
Thanks in advance.
Fresco supports different network stacks. For example, you can use OkHttp with Fresco, which should follow redirects or modify the default one to allow redirects - or write your own based on them.
Guide for OkHttp: http://frescolib.org/docs/using-other-network-layers.html
Related GitHub issue: https://github.com/facebook/fresco/issues/61
I found a solution for this problem (but could be only applicable if you use Google Cloud or Google Script).
It consists on creating a doGet() service with the following code inside:
var file = DriveApp.getFileById(fileId)
return Utilities.base64Encode(file.getBlob().getBytes());
and use that base64 value in your app. With this format, Fresco can do the magic
It is not an immediate solution, and requires to do somework in other platform that is not your Android app, but it works perfectly.
Are you sure that there is no problems with your URLs?
Picasso works with direct URLs like: https://kudago.com/media/images/place/06/66/06662fda6309ce1ee9116d13bd1c66d5.jpg
Then you can download your image like:
Picasso.with(this)
.load(url)
.noFade()
.placeholder(R.drawable.placeholder_grey) //if you want to use a stub
.into(imageView, new com.squareup.picasso.Callback() {
#Override
public void onSuccess() {
//here you can operate with image after it is downloaded
}
#Override
public void onError() {
}
});
Hope it will help you.

How To Get Clear Image From FaceBook

I used graph API Json Response of Facebook Wall Post Images and display in my APP i successfully got it. But the wall images look very Blur how to resolve? i used this code for get wall picture
URL url=new URL(hashMap.get("picture_url"));
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
((ImageView)view.findViewById(R.id.imageView_FullImage)).setImageBitmap(bitmap)
The Facebook Graph API as well as the FQL data set always returns the Picture URL of a thumbnail. If you look at the URL it returns, it will have one of these ending (right before the image extension .jpg, .png, etc) _t., _a.. For example, if the URL is to a JPG file, it could have an ending _t.jpg
The idea is to swap the ending and choose a normal size for the image that is returned. To do this, use the code below that will replace the endings with the one for normal sized images (that should have the _n.)
By the way, I don't think the tag you are looking for is picture_url. It should be just picture. But regardless, get the source URL as shown below, replace the endings and then pass it to the this line in your code:
// THIS SHOULD BE AFTER THE if....else code block
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
CODE TO REPLACE THE VARIOUS THUMBNAIL IMAGES: By the way, this is production code and works perfect.
String PICTURE_URL;
String getPicture = JOFeeds.getString("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
Note: However, in some cases, like a Video preview or a Link preview, it will not always have a bigger image available. Nothing much you can do about it nor can Facebook I suspect. These typically come from posts that are shared by users from other websites.

retrieving images from Picasa on android

hello am trying to get images from an album from picasa in an android app. I tried creating an album and the album was created successfully however there is something wrong when i try to get the images in the album. Please find below my code:
PicasawebService myService = new PicasawebService("myApp");
myService.setUserCredentials("username", "password");
URL url = new URL ("https://picasaweb.google.com/data/feed/api/user/myusername/albumid/myalbumid");
AlbumFeed feed= myService.getFeed(url, AlbumFeed.class);
List<MediaContent> l;
for(PhotoEntry photo : feed.getPhotoEntries()){
l= photo.getMediaContents();
return l.get(0).getUrl().toString();
}
the for loop is not being entered but when i check the size of the feed and it shows me the correct number of images in the album. I got the code from google developers guide:(https://developers.google.com/picasa-web/docs/2.0/developers_guide_java#listalbums)
NB: i tried the same exact code in a desktop app and worked perfectly.
Thank you
EDIT: The problem is that the ALbumFeed is returning entries of class GPhotoEntry and not PhotoEntry. I searched online and the solution was to include the gdata-photos-meta.jar in my library which was already included...Any idea?
google's GData doesnt work with android. You should use google Client api and they say that there is a running sample for picasa on android.

Categories

Resources