2012-01-27 78 views
0

*完成PHP noob这里。我试图写简单的PHP,返回一个tumblr头像。 Tumblr有一个地址可以导航到,以撤消博客头像。例如导航到:Tumblr API Avatar

http://api.tumblr.com/v2/blog/david.tumblr.com/avatar/512

导致这个:

http://27.media.tumblr.com/avatar_a963092d964b_512.png

我只是想在巴纽地址作为一个变量。这是我得到的,但它只是吐出一大页奇怪的文字。

<?php 
$avatar = file_get_contents("{the link above, I can only have two hyperlinks in a post}"); 
echo $avatar; 
?> 

我假设file_get_contents不是我想要的,但我不知道要用什么。

回答

0

你试过:

<?php 
$avatar = "http://27.media.tumblr.com/avatar_a963092d964b_512.png"; 
echo $avatar; 
?> 
0

您可以使用官方PHP Tumblr Client,只是提供您的消费者的关键。

// 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 

然后这将返回图像的URL。

您可以参考本作更多的tumblr API阿凡达终点和其他 https://api.tumblr.com/console/calls/blog/avatar