Tumblr API Gets Current AVATAR URL

Everyone knows? about url avatar in tumblr api / read / json? e.g. facebook?

http://graph.facebook.com/[your facebook id] / picture? type = normal

<?php $tumblog = 'natadec0c0'; // change to your username // if your Tumblog is self hosted, you need to change the base url to the location of your tumblog $baseurl = 'http://' . $tumblog . '.tumblr.com'; $request = $baseurl . '/api/read/json'; $ci = curl_init($request); curl_setopt($ci,CURLOPT_RETURNTRANSFER, TRUE); $input = curl_exec($ci); curl_close($ci); // Tumblr JSON doesn't come in standard form, some str replace needed $input = str_replace('var tumblr_api_read = ','',$input); $input = str_replace(';','',$input); // parameter 'true' is necessary for output as PHP array $value = json_decode($input,true); $content = $value['posts']; $blogInfo = $value['tumblelog']; // the number of items you want to display $item = 10; // Echo the blog info echo "<h3><a href=\"" . $baseurl . "\">" . $blogInfo['title'] . "</a></h3>\n"; echo "<h4>" . $blogInfo['picture'] . "</h4>\n<hr />\n"; ?> 

How to add my current avatar?

+4
source share
2 answers

I think you should use

 GET http://www.tumblr.com/api/ authenticate?email=user@example.com &password=12345 

to get the user avatar. The answer to the sample for my part is

 <tumblr version="1.0"> <user default-post-format="html" can-upload-audio="1" can-upload-aiff="1" can-ask-question="1" can-upload-video="1" max-video-bytes-uploaded="26214400" liked-post-count="134"/> <tumblelog title="ABNKKPGPiCTuReNPLaKo?!" is-admin="1" posts="301" twitter-enabled="0" draft-count="0" messages-count="0" queue-count="" name="arvn" url="http://arvn.tumblr.com/" type="public" followers="17" avatar-url="http://28.media.tumblr.com/avatar_b1786ec9e62d_128.png" is-primary="yes" backup-post-limit="30000"/> <tumblelog title="i kras yu." is-admin="1" posts="1" twitter-enabled="0" draft-count="0" messages-count="0" queue-count="" name="ikrasyu" url="http://ikrasyu.tumblr.com/" type="public" followers="2" avatar-url="http://25.media.tumblr.com/avatar_02a7ef66fce8_128.png" backup-post-limit="30000"/> </tumblr> 

and get the avatar-url field of the corresponding buffer. Too bad there is no json format, maybe use preg_match. You also need an email address and user password, or do this through OAuth .

Or you can clear the avatar folder.

 $page = file_get_contents("http://{$tumblog}.tumblr.com/"); $avatar = preg_match('/<img src="(http.+)" alt="portrait"/', $page, $matches) ? $matches[1]: 'http://example.com/blank.png'; 
0
source

The best solution for this is to put the api avatar in the img tag.

 api.tumblr.com/v2/blog/{base-hostname}/avatar[/size] example: <img src='http://api.tumblr.com/v2/blog/myreallycoolblog.tumblr.com/avatar/48'/> 

So, as long as you have blogname, you can display the avatar.

+7
source

All Articles