mesingh/envato-api

这是一个用于 Envato 市场如 themeforest.net 的 PHP 包装类。

dev-master 2013-10-22 13:04 UTC

This package is not auto-updated.

Last update: 2024-09-19 03:17:37 UTC


README

这个类是 Envato 市场API的包装器。它提供了易于记忆的方法来查看您的项目,搜索市场,获取个人,私有数据,查看收藏夹等。它还会自动缓存结果,这样您就不必无谓地猛击API了!

用法

首先,在您的项目中包含该类。

require 'Envato_marketplaces.php';

接下来,创建该类的新实例

$Envato = new Envato_marketplaces();

就是这样。您现在可以访问所有可用的函数。

示例

快速显示用户的缩略图

$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();