ThemeForest

Envato API

629 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Bought between 10 and 49 items
  • United States
  • Referred between 10 and 49 users
VagrantRadio says

I’ve searched the forums, Google, etc. and I’m putting something together with the Envato API but the documentation quite frankly sucks.

What I’m trying to do is put mimic the author statement like so:

22 May 10 sale $ 0.00 sold Your Item Here for 1.00 w/ rate of 00.0%

Here’s what I have so far:

 <?php // List Recent Sales
            $count = 1;
            $salesArray = $json_data['recent-sales'];
            foreach($salesArray as $value)
            {
                if($count <= 10)
                {
                    echo "<li class='line?><span class="sold">".$json_data['vitals']['username']." Sold ".$value['item']." at ".$value['rate']."%</span><span class="price">$".$value['amount']."</span>";
                    $count = $count + 1;
                }
                else
                {
                    break;
                }
            }
        ?>

but that just puts out:

Author Username Your Item Here at 0.00% $1.00

Can anyone tell me how to get the values from the API to achieve the values I’m looking for?

2 years ago via ThemeForest |
629 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Bought between 10 and 49 items
  • United States
  • Referred between 10 and 49 users
VagrantRadio says

Nevermind, found it.

<?php $userName = 'yourusername';
$apiKey = 'yourapikey';   
$json_url = "http://marketplace.envato.com/api/edge/".$userName."/".$apiKey."/vitals+recent-sales.json";
$rawdata = file_get_contents($json_url);
$json_data = json_decode($json_contents, true); // 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

?> 
2 years ago via ThemeForest |
1962 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Peru
  • Referred between 200 and 499 users
crozer says

Sounds interesting; let me know when you’re finished to test it :D

2 years ago via GraphicRiver |
2425 posts Customer Service Manager aka SuperDrew
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Attended a Community Meetup
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Support Staff
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 10 and 49 users
CreatingDrew says

You might find this article useful – http://blog.themeforest.net/tutorials/display-anything-you-want-from-the-envato-api-using-php/

Just a note as you touched on in the code, using cURL is much, much faster than file_get_contents, albeit requires a few more lines of code. As always I suppose it just depends on what best suits your needs :)

2 years ago via ThemeForest |
CreatingDrew is an Envato staff member
629 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Bought between 10 and 49 items
  • United States
  • Referred between 10 and 49 users
VagrantRadio says
You might find this article useful – http://blog.themeforest.net/tutorials/display-anything-you-want-from-the-envato-api-using-php/ Just a note as you touched on in the code, using cURL is much, much faster than file_get_contents, albeit requires a few more lines of code. As always I suppose it just depends on what best suits your needs :)

Here’s a little teaser, crozer.

Thanks Drew, that article is what the first lines of code are from. I was just trying to put together something that would spit out all the values I was looking for and then I ran across this thread and simply switched out the code for the new values.

2 years ago via ThemeForest |
6468 posts
  • Has been a member for 4-5 years
  • Won a Competition
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Beta Tester
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Bought between 50 and 99 items
  • United Kingdom
  • Referred between 10 and 49 users
MSFX says
Here’s a little teaser, crozer.

oooooo, looking pretty slick :)

2 years ago via ActiveDen |
MSFX is a moderator
659 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • United States
  • Referred between 10 and 49 users
luckykind says
Here’s a little teaser, crozer.
oooooo, looking pretty slick :)

+1 – slick indeed…

2 years ago via ThemeForest |
1962 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Peru
  • Referred between 200 and 499 users
crozer says

Nice, really. I hope you don’t keep it for yourself :O

2 years ago via GraphicRiver |
by
by
by
by
by