For that authentication is needed. To authenticate with tumblr we need consumer key and consumer secret key.We will have to register in developer portion of tumblr. And after then I will get consumer key and consumer secret key.

And after then We get oauth_token and oauth_secret. After then by oauth_token, oauth_secret, consumer key and consumer secret, we get blogname and details of default blog and created blog.

To get blogname of tumblr

$connection = new TumblrOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauthtoken, $oauthtsecretoken);

$user = $connection->authenticate();
$tumblruser = simplexml_load_string($user);
$tumbuser = ClUtilityFunctions::SimpleXMlobjectToArray($tumblruser);
//print_r($tumbuser);  exit;
$name = (string)$user->tumblelog[‘name’];

$tumbusr=$tumbuser[‘tumblelog’];

 

To get the details of every blog like text, picture and so on in tumblr

$request_url = ‘http://’.$tumblrblogname.’.tumblr.com/api/read?start=0&num=2′;
$xml = simplexml_load_file($request_url);
$posts = $xml->xpath(“/tumblr/posts/post”);
$tumbpost = ClUtilityFunctions::SimpleXMlobjectToArray($posts);

[Note: SimpleXMlobjectToArray is simpleXML object to Array function.]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.