Using the Duolingo API with PHP to Get Profile Data
For those who are interested in learning a new language, Duolingo is a great place to start. It’s free, and some recent studies suggest that it’s more effective than Rosetta Stone (which is not free).
I’ve been using Duolingo for the past few months and decided to do something similar with my Duolingo profile as I did with my Code School profile – put it on the sidebar of this blog.
However, I soon discovered that I could not do that, as Duolingo’s terms of service banned Web scraping. Fortunately, I discovered that an API is available!
Using this API, I was able to write a PHP script that I host which will pull a user’s data, then filter out only language information that is pertinent (to this particular task).
\n";
$html = $html . $temp_html;
}
}
/* close anchor tag and inner div */
$html = $html . "\n";
$html = $html . "
\n";
/* return the html */
echo $html;
/* uncommenting below will show full contents of JSON from languages section */
//$languages_json = json_encode($languages);
//echo $languages_json;
?>
If you want to put this on WordPress, create a Text widget and insert the following code. This assumes that you are hosting duolingo.php in the root directory. Also, change the username in the querystring as appropriate.
You must log in to post a comment.