Quickstart on PHP

Hello coders!
I’m so exited about the introduction of the API that I needed to share my personal code that I use to test this new feature.

This example code will get the non-experienced coders started in testing and playing with the new API . It uses JSON instead of the more logical XML only because it’s more fun to play with when you want speed and not elegance (I might do this again in XML some time).

$url = ”$api$version/$username/$apikey/$sets.json”;
$rawdata = file_get_contents($url); // We get the contents, if you have remote locations disabled in your php.ini, you can use curl or something else here to get the actual HTTP data
$data = json_decode($rawdata, true); // Sets $data variable as the decoded json file in array

// Up to you (I’m assuming you know what to do with the array)
print_r($data); // This example just outputs the data, could be usefull for debugging

Post Reply

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody