Simple Kred API Example

  • follow us in feedly
Published July 15, 2013 by Brad Knutson
Kred API Example

I’ve been on a bit of a “Social Authority” (or “Influence” depending on what side of the fence you are on…) kick lately. I’ve been playing with some different social scoring APIs and having a little fun with them.

I came across Kred quite a while ago. The service has come a long way in the last few months, and I’ve noticed some major performance and design improvements on the site. This prompted me to give the API a second look, and see what I could come up with.

Let’s say that all I want is to get a Twitter users Kred Influence Score and Outreach Score. Perhaps you want to do some quick research on a client or competitor.

First – you’ll need to register an app and get your app ID and app key. Do so at https://developer.peoplebrowsr.com/

Next, we’ll need to build our API call. My weapon of choice is PHP, but you could certainly use Python or Ruby.

PHP

$app_id = "App_ID";
$app_key = "App_Key";
$user = "Twitter Username";
$URL = 'http://api.kred.com/kredscore?app_id='. $app_id .'&app_key='. $app_key .'&term='. $user .'&source=twitter'; 
$kred_response = json_decode( file_get_contents( $URL ), true );

We now have our response. It looks something like this:

Kred API Response

As you see, the Kred Influence and Outreach scores are there, we just need to grab them!

$kred_score = $kred_response['data'][0]['influence'];
$kred_outreach = $kred_response['data'][0]['outreach'];

I have found that the API sometimes hangs, and can hold up the rest of your page. If you are not using AJAX to get the Kred Influence, then make sure you set a timeout.

ini_set('default_socket_timeout',3);

That’s pretty much it – really straight forward. If you want to see this in action, head over to http://mysocialauthority.com and enter your Twitter username.

The following two tabs change content below.
Founder at Inbounderish
Brad Knutson is a Web Developer in the Twin Cities area of Minnesota. He has experience working with WordPress and Drupal, and also has an interest in SEO and Inbound Marketing.

Keep Up-to-Date

Subscribe

Topics

See a complete list of topics discussed in blog posts here.

Check These Out

Get 2 Weeks Free! Sign Up Today! Premium Managed WordPress Hosting Genesis Framework for WordPress SEO is complex. Tools should be simple. Thesis Theme for WordPress:  Options Galore and a Helpful Support Community

Share Your Thoughts

Your email address will not be shown.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">