Tumblr is the most popular social platform for setting up your blogs. Tumblr has provided Tumblr API to make any operation on your Blogs. In this article, I am explaining the simplest procedure to integrate Tumblr API.
Steps to Configure Tumblr API with PHP
First register an app to get the consumer key and secret. Click the link below
https://www.tumblr.com/oauth/register
You will see the form like below:
The administrative contact email field will contain the email id registered with your Tumblr account. Provide a valid value in Default callback URL
Application Website, App Store URL, and Google Play Store URL can be left blank at the moment. And submit the form. On the next page, you will get your OAuth Consumer key and secret key.
Just save these for future use.
Now to obtain, Oauth token and token secret, go to the following URL:
https://api.tumblr.com/console/calls/user/info
Here input your Consumer Key and Consumer Secret and click Authenticate to get the OAuth token and token secret along with PHP code to set up the authentication.
If keys are not shown, you can see those by clicking the show keys button on the top.
Now Lets us Start Some Coding Work
To get the API code, you just need to get the PHP repository available at GitHub. But the best way to get this code to install this repository using composer as i did.
You May Also Like:
How to Make Soap Client Call in PHP
Create and Save XML file Using MySQL Data in PHP
Configure Intercom API in PHP and Create New User in It
GitHub Tutorial: Commit, Push And Go
How to Integrate Instagram API into Website
How to Create Rss Feed Script Using PHP and MySQL
Open the command prompt and go to the path where you want to install the repository and type the command
php composer.phar require tumblr/tumblr
1 |
C:\xampp\htdocs\tumblr >php composer.phar require tumblr/tumblr |
This will install the Tumblr repository at your system along with required dependencies (inside C:\xampp\htdocs\tumblr directory, in my case.) Now on the root path, create “sample.php” with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php require_once('vendor/autoload.php'); $client = new Tumblr\API\Client( 'Your Oauth Consumer Key', 'Your Consumer Secret', 'Your OAuth Token ', 'Your Token Secret' ); $info = $client->getUserInfo(); echo "<pre>"; print_r($info); ?> |
This will get you the basic information about the Tumblr user. Likewise, you can make any other operation on your blog(s) by following the Tumblr api documentation.
Hope this article would benefit you. Please share if you like this article. Thanks