User Information via Loklak API

While working on “adding loklak API support to  wordpress plugins”, I found that a lot plugins require Twitter user information e.g. profile_pic, followers_count, tweets by the user etc.

One can get an exhaustive user information using Loklak search and user APIs. In this blog post I would show how one can combine the results from Loklak’s Search and User API to provide all kinds of data required by a WordPress plugin (e.g.).

Starting with Search API!


in url would give you results like this:


As you can see, it provides all tweet (tweeted by the <user>) related information and a small user profile like this:


But what if you require his location, followers_count, friends_count, no. of tweets he has posted till now etc, you would have to take help from the Loklak User API. Sample results for

are given below:


But somehow you also require the information of his followers and people he is following. How do you achieve that? Well Loklak API has provision for that as well. All you need to do is add followers=<count> or following=<count> as need be.

Following data would be added to your user.json results.


It would give you the user information of twitter users followed by that user. Recursively you can get their tweet data, their followers and on and on!!

In order to get complete user profile, you can merge the results from Search and User API and create wonderful applications.

To do all this using Loklak PHP API, refer to the code snippet below.

$connection = new Loklak();
$tweets = $connection->search('', null, null, $username, $no_of_tweets);

$tweets = json_decode($tweets, true);
$tweets = json_decode($tweets['body'], true);

$user = $connection->user($username);
$user = json_decode($user, true);
$user = json_decode($user['body'], true);

$tweet_content = $tweets['statuses'];
for ($i=0; $i < sizeof($tweet_content); $i++) {
     $tweet_content[$i] = array_merge($tweet_content[$i], $user);
User Information via Loklak API

Loklak : Map your Tweets!

The heading must have aroused your interest what it is about, but let me first tell you about Loklak.Loklak is a tool which you can use to anonymously scrap the tweets from twitter.Such a great back-end API needs an awesome enough front-end tool!That’s what we are developing this year as GSOC Students.The Loklak Front End, currently in its pre-alpha stage just completed its 1st phase out of 4, so I will be talking what we have achieved till now.I am working on the Maps feature so I will mostly speak about it

The Tweet Map feature allows the user to visualise the tweets as they are tweeted by the users on world maps as markers.The markers will show the tweet content in a popup with other related content like the username, time, location and links.The current stage is updated regularly and can be seen here. You can also try the wall feature thats another dimension.


Technologies I am using

Loklak Frontend is built on AngularJS as most of us developers share a love for JS here at Loklak.I am using Leaflet libraries to handle the Map related features.Currently I am using a inline geoJSON Variable to plot the markers on the map, soon it will be plotted from a jsonp request to server.

Its just a start to an awesome ending, once the whole feature is complete a user can select a region to show the tweets in, put in a name of a place and retrieve its tweet on the world map.Just imagine you want to see whats trending where the most? Just put in a #tag and you can see the density or may be heatmap! Its just way too cool! It has lots of potential and we are just scratching the surface. If you would like to join the development. Join us on Github, chat with us on Gitter.

Thats all for now! Next week new developments new post!

Loklak : Map your Tweets!