Reputation: 3856
*Complete PHP noob here. I'm trying to write simple php that returns a tumblr avatar. Tumblr has an address you can navigate to, to retreve the blog avatar. For example navigating to:
http://api.tumblr.com/v2/blog/david.tumblr.com/avatar/512
leads to this:
http://27.media.tumblr.com/avatar_a963092d964b_512.png
I simply want the .png address as a variable. Here's what I got but it just spits out a big page of strange text.
<?php
$avatar = file_get_contents("{the link above, I can only have two hyperlinks in a post}");
echo $avatar;
?>
I assume the file_get_contents is not what I want to use but I don't know what to use.
Upvotes: 0
Views: 787
Reputation: 3038
You can use the official PHP Tumblr Client and just provide your consumer key.
// Authenticate via API Key
$client = new Tumblr\API\Client('yourkeyhere');
// Make the request
$client->getBlogAvatar('yourblog.tumblr.com', 16); //You can choose different size here on the second parameter
then this will return the URL of the image.
You can refer to this for more of the Tumblr API Avatar Endpoint and others https://api.tumblr.com/console/calls/blog/avatar
Upvotes: 1
Reputation: 65351
Have you tried:
<?php
$avatar = "http://27.media.tumblr.com/avatar_a963092d964b_512.png";
echo $avatar;
?>
Upvotes: 0