/ Published in: PHP
Script used to access the Envato API, and get extra details using Curl.
This script will only work on PHP5 on a Linux hosting account (with safe mode / openbasedir disabled). Will need slight adjustment if trying to run it otherwise.
You are welcome to use or modify this script, feel free to share your implementation of it.
This script will only work on PHP5 on a Linux hosting account (with safe mode / openbasedir disabled). Will need slight adjustment if trying to run it otherwise.
You are welcome to use or modify this script, feel free to share your implementation of it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$envato = new envato(); $files = $envato->get_user_items('dtbaker','codecanyon'); $x=1; echo '<ul>'; foreach($files as $file){ if($x++>9)break; echo '<li>'; echo $file['item']; echo '</a>'; echo ' <span class="small">($'.$file['cost'].')</span>'; echo '</li>'; } echo '</ul>'; class envato{ private $_temp_folder; private $_ch; public function __construct(){ } } $data = false; if(!$force){ // check if the cache item exists. $filename = $this->_temp_folder.$cache_id; } } } if(!$data){ // no cache item found, so we grab it via curl. }else{ } } if(!$force){ // save cache item. } if($clean)$data = $this->_clean($data); return $data; } public function get_item($item_id){ $url = "http://themeforest.net/item/daves_api/$item_id"; $data = $this->grab_url($url); $return['large_thumb'] = $matches[1]; } $return['content'] = $text[1]; } } // we also have to get the theme screenshot thumbnails $url = "http://themeforest.net/theme_previews/$item_id-daves_api"; //print_r($matches); foreach($matches[2] as $thumbnail){ } } } return $return; } public function get_user_items($user,$marketplace='themeforest'){ $url = "http://marketplace.envato.com/api/v2/new-files-from-user:$user,$marketplace.json"; $data = $this->grab_url($url); $files = $json_data['new-files-from-user']; // sort files? meh. return $files; } } /** private functions **/ private function posterize($post){ $postv = ''; foreach($post as $key=>$val){ $postv .= $key .'='.$val.'&'; } return $postv; } private function _clean($data){ } }
URL: http://dtbaker.com.au/random-bits/basic-usage-of-the-envato-api-plus-curl-.html