23 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Has been part of the Envato Community for over 6 years
+2 more
Lahdekorpi says

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).

I got the example username and api-key from the introduction post (http://themeforest.net/forums/thread/a-brief-introduction-to-the-api/10945)

I used json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0)

Colored version of the code: http://lygon.net/themeforest.phps

<?php <br?>$api = “http://marketplace.envato.com/api/”; // Url of the actual API
$version = “edge”; // Edge is the development version, releses will be numbers
$username = “ryan”; // Your username
$apikey = “26k6otse2s586e4hcbzjy3quq830t3o4”; // Your api key
$sets = “vitals+recent-sales”; // sets you want to get. Format: set+otherset+etc


$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

?> $version 

578 posts
  • Has been part of the Envato Community for over 8 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1+ on Envato Market
+6 more
ryan says

That is brilliant!

May I suggest using http://pastie.caboo.se for code samples? That way we probably wont have any problem with our forums bonking up the code :)

But thanks!

Also, if anyone is doing a JS or AS example, remember you can just get the JSON response and go data = eval(response) and then access it like data['vitals']['balance'] !!!

105 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
Short says

Great :D

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<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

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by