vinch/kloutbe — pull request #5 by matthiasmullie (2013-05-12 18:58:08+00:00)
Title: This will make kloutbe work with Klout API v2

Hi,

The "bad" thing about Klout API v2 is that it is (at least I could not immediately find it) not possible to fetch the Klout scores of multiple users at once. As a result, a lot more calls (1 per user) need to be performed to Klout API.

This pull request will change the API calls to match APIv2.

Klout API makes it impossible to fetch Klout scores from Twitter handles right away. First, the Klout id needs to be retrieved, then from that Klout id, the score.
This also had implications for schema (added column `kid`) and import.php (which now has to fetch `kid` for all users).
For the production site, I'd suggest to first export the existing usernames into a fresh list.txt, truncate the table, add the new column (see below) and run import.php (on the new list.txt). After that, everything should be back up and running.

ALTER TABLE `users` ADD `kid` varchar(255) AFTER `twitter_screen_name`;

A minor amount of code cleanup has been done too:
* refresh.php & force.php were similar; they'll not use mostly the same code (in model.php) rather than duplicate the code
* import.php now needs to more complex (we need to fetch and save Klout id) and more closely match submit.php; both will now use model.php
* Klout API calls have been separated into klout.php