0

I´m struggeling a bit trying to get the URL of a PhotoPost using jumblr. I tried casting a post to a PhotoPost, but the detail says that there is no link ( i guess that is what i´m looking for) All i want is the link to the jpg.

    List<Post> posts = client.userDashboard();
    PhotoPost photoPost = (PhotoPost) posts.get(0);
    System.out.println(photoPost.detail());

    {date=2015-06-15 23:14:28 GMT, format=html, link=null, caption=<blockquote><p>“…You win.”
    <br/></p><p>“I know.”</p></blockquote>, state=published, type=photo, slug=you-win-i-know,

I hope someone might have an idea.

Thanks alot!

Charles
  • 17
  • 5

1 Answers1

3

The Jumblr API can be very confusing and the examples aren't showing everything. I had the same problem and this worked for me:

Map<String, Object> params = new HashMap<String, Object>();
params.put("type", "photo");
List<Post> posts = client.blogPosts("YOURBLOGNAME.tumblr.com", params);
PhotoPost photoPost = (PhotoPost) posts.get(0);
System.out.println(photoPost.getPhotos().get(0).getOriginalSize().getUrl());

Change YOURBLOGNAME with your blogname. If "YOURBLOGNAME.tumblr.com" isn't working, use "YOURBLOGNAME.com" instead. This code gets the first image (pho.getPhotos().get(0)) of the first post ((PhotoPost) posts.get(0)).

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
  • Why was my answer edited to that nonsense with my account? Hmm... Well, whatever. Thank you Infinite Recursion to change it back – JumblrHelper Jun 23 '15 at 20:23