This class is a wrapper for the Envato Marketplace API. It provides easy-to-remember methods to view your items, search the marketplace, get personal, private data, view collections, etc. It also will automatically caches the results - so that you don't hammer the API needlessly!
First, include the class in your project.
require 'Envato_marketplaces.php';
Next, create a new instance of the class:
$Envato = new Envato_marketplaces();
And that's really it. You now have access to all of the available functions.
$Envato = new Envato_marketplaces();
$Envato->display_thumbs('your username', 'desired marketplace name', 'number to display');
$Envato = new Envato_marketplaces();
$sliders = $Envato->search('sliders');
$Envato->prettyPrint($sliders);
$Envato = new Envato_marketplaces();
$sliders = $Envato->search('sliders', 'codecanyon');
$Envato->prettyPrint($sliders);
$Envato = new Envato_marketplaces();
$sliders = $Envato->search('sliders', 'codecanyon', 'plugins');
$Envato->prettyPrint($sliders);
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces( 'YOUR_API_KEY');
# Echo out the balance.
echo $Envato->balance('your username');
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$featured = $Envato->featured('codecanyon');
# Just for reviewing available props
$Envato->prettyPrint($featured);
# Featured author
echo $featured->featured_author->user;
# Featured file
echo $featured->featured_file->url;
#Free file
echo $featured->free_file->url;
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
# Pass in item id -- see url on item page on the marketplace.
$item = $Envato->item_details('232428');
# Only for development purposes. Review available options.
$Envato->prettyPrint($item);
?>
<h2> <?php echo $item->item; ?></h2>
<a href="<?php echo $item->url; ?>">
<img src="<?php echo $item->live_preview_url; ?>" alt="<?php echo $item->item; ?>" />
</a>
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
# marketplace name, desired category, optional limit (number of items to return)
$files = $Envato->new_files_from_user('Your Username', 'desired marketplace name', 5);
#See what we got back...
$Envato->prettyPrint($files);
# Display thumbnails and links to the item pages.
foreach($files as $item) : ?>
<a href="<?php echo $item->url; ?>">
<img src="<?php echo $item->thumbnail; ?>" />
</a>
<?php endforeach; ?>
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->set_api_key('your api key');
$sales = $Envato->recent_sales('your username', 'optional limit');
# Review what we got back
$Envato->prettyPrint($sales);
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->set_api_key('your api key');
$monthly_earnings = $Envato->earnings_by_month('your username', 'optional limit');
# For review...
$Envato->prettyPrint($monthly_earnings);
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->set_api_key('your api key');
$account_info = $Envato->account_information('your username');
# See what we got back....
$Envato->prettyPrint($account_info);
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$pop = $Envato->most_popular_last_week('marketplace name');
# Result Array
$Envato->prettyPrint($pop);
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->set_api_key('your api key');
// Ensure that somebody bought your item.
// If successful, $verify will be an object which
// contains all of the purchase information.
$verify = $Envato->verify_purchase('your username', 'buyer purchase code');
// Quickie test.
if ( isset($verify->buyer) ) echo 'bought';
else echo 'did not buy';
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->cache_dir = 'path/to/directory'; // defaults to 'cache'
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
// ...
$Envato->clear_cache();