/** * Sets the base URL. * * Base hostname format is defined here: http://www.tumblr.com/docs/en/api/v2#overview * * @param array $options * @return mixed */ public function __construct(array $options = NULL) { if (!isset($options['base_hostname'])) { throw new Kohana_OAuth_Exception('Required option not passed: base_hostname must be provided'); } // Set base URL $this->base_url .= "/blog/{$options['base_hostname']}"; parent::__construct($options); }
function processPage($p = 0) { $tumblr = new Tumblr($_SESSION["tumblr"], "fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4"); $giflib = new GifLib(); $clean_array = $tumblr->load($p); $clean_array_compressed = array(); foreach ($clean_array as $key => $post) { $clean_array_compressed[]["title"] = $post["title"]; $clean_array_compressed[count($clean_array_compressed) - 1]["id"] = substr($giflib->gifOrgName($post["gif"]), 0, -4); if (!$giflib->isGifCached($post["gif"])) { if (!$giflib->isCompressionRunning($post["gif"])) { $giflib->compressGif($post["gif"]); } $clean_array_compressed[count($clean_array_compressed) - 1]["gif"] = "static/preloader.gif"; #TODO auto refresh via javascript } else { $clean_array_compressed[count($clean_array_compressed) - 1]["gif"] = "gifs/compressed_" . $giflib->gifOrgName($post["gif"]); } } return $clean_array_compressed; }
<?php /* "THE BEER-WARE LICENSE" (Revision 42): * Jaap Broekhuizen <*****@*****.**> wrote this file. As long as you retain * this notice you can do whatever you want with this stuff. If we meet some * day, and you think this stuff is worth it, you can buy me a beer in return. */ require_once '../src/Tumblr.php'; $tumblr = new Tumblr(); $tumblr->setApiKey('pYiJYdRAFJHgQl7ekaVirCiYg8IRiVOp5ONDZ2PziJFXmVEwhv'); $blogInfo = $tumblr->blogInfo('jaapz.tumblr.com'); var_dump($blogInfo);
/** * Sets the base base URL. * * @param array $options * @return void */ public function __construct(array $options = NULL) { // Set base URL $this->base_url .= '/user'; parent::__construct($options); }
<?php /* "THE BEER-WARE LICENSE" (Revision 42): * Jaap Broekhuizen <*****@*****.**> wrote this file. As long as you retain * this notice you can do whatever you want with this stuff. If we meet some * day, and you think this stuff is worth it, you can buy me a beer in return. */ require_once '../src/Tumblr.php'; // Set up OAuth first. Another example on how to authenticate using the OAuth // way can be found here: // http://svn.php.net/viewvc/pecl/oauth/trunk/examples/twitter/fetchTimeline.php?annotate=280252 $oauth = new OAuth('pYiJYdRAFJHgQl7ekaVirCiYg8IRiVOp5ONDZ2PziJFXmVEwhv', '9JRVserz6M2lj2l679k73ktWQWvmLIFLFdMgHBBmB0DxFGV0lu', OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth->enableDebug(); // Get token using the API. $requestToken = $oauth->getRequestToken('http://www.tumblr.com/oauth/request_token'); echo 'Go to: http://www.tumblr.com/oauth/authorize?oauth_token=' . $requestToken['oauth_token'] . "\n"; echo 'After visiting and authorizing, hit ENTER here.' . "\n"; $in = fopen('php://stdin', 'r'); fgets($in, 255); echo "Getting access token...\n"; $oauth->setToken($requestToken['oauth_token'], $requestToken['oauth_token_secret']); $accesToken = $oauth->getAccessToken('http://www.tumblr.com/oauth/access_token'); $oauth->setToken($accessToken["oauth_token"], $accessToken["oauth_token_secret"]); // Instantiate the Tumblr API wrapper with the OAuth object, and our API Key. $tumblr = new Tumblr(); $tumblr->setOAuth($oauth); $tumblr->setApiKey('pYiJYdRAFJHgQl7ekaVirCiYg8IRiVOp5ONDZ2PziJFXmVEwhv'); $dashboard = $tumblr->dashboard(); var_dump($dashboard);
<?php date_default_timezone_set('America/Los_Angeles'); $url_prefix = 'http://noonat.phuce.com'; include 'php/tumblr.php'; $tumblr = new Tumblr('noonat'); ob_start(); $action = isset($_GET['action']) ? $_GET['action'] : null; if ($action === 'post') { $tumblr->read(array('id' => $_GET['post_id'])); include 'php/_posts.php'; } elseif ($action === 'search') { $tumblr->read(array('search' => $_GET['q'])); include 'php/_search.php'; } else { $tumblr->read(); include 'php/_posts.php'; } $body = ob_get_clean(); include 'php/_layout.php';
public function update_tumblr() { $api_key = trim(ESSBSocialFollowersCounterHelper::get_option('tumblr_api_key')); $api_secret = trim(ESSBSocialFollowersCounterHelper::get_option('tumblr_api_secret')); $access_token = trim(ESSBSocialFollowersCounterHelper::get_option('tumblr_access_token')); $access_token_secret = trim(ESSBSocialFollowersCounterHelper::get_option('tumblr_access_token_secret')); $basename = trim(ESSBSocialFollowersCounterHelper::get_option('tumblr_basename')); if (empty($api_key) || empty($api_secret) || empty($access_token) || empty($access_token_secret) || empty($basename)) { return 0; } if (!class_exists('Tumblr')) { require_once ESSB3_PLUGIN_ROOT . 'lib/modules/social-followers-counter/Tumblr/Tumblr.php'; } $tumblr = new Tumblr($api_key, $api_secret, $access_token, $access_token_secret); $response = $tumblr->followers($basename); if (!$response || !is_object($response)) { return 0; } if (isset($response->response) && isset($response->response->total_users)) { return $response->response->total_users; } }
<?php // Set the following parameters $tumblrEmail = ''; $tumblrPassword = ''; $file = ''; // location of exported wordpress xml $categories = array(); // ex blog, news, videos $oldDomain = ''; // ex mywordpress.com (set this if you want relative links in posts converted to absolute before importing… note this should only be done if your old site will be set up to forward links to your new one.) $resolver = array(); $tumblr = new Tumblr(); $tumblr->setCredentials($tumblrEmail, $tumblrPassword); $wpt = new WordpressToTumblr(); $wpt->setWordpressXmlFile($file); $wpt->loadXML(); $wpt->setTumblrObject($tumblr); $wpt->postToTumblr(); class WordpressToTumblr { private $wpExportFile; private $xml; private $tumblr; public function setWordpressXmlFile($file) { $this->wpExportFile = $file; } public function loadXML() { $this->xml = simplexml_load_file($this->wpExportFile);
public static function tumblr() { $api_key = trim(ESSBSocialFansCounterHelper::get_option('tumblr.api_key')); $api_secret = trim(ESSBSocialFansCounterHelper::get_option('tumblr.api_secret')); $access_token = trim(ESSBSocialFansCounterHelper::get_option('tumblr.access_token')); $access_token_secret = trim(ESSBSocialFansCounterHelper::get_option('tumblr.access_token_secret')); $basename = trim(ESSBSocialFansCounterHelper::get_option('tumblr.basename')); if (empty($api_key) || empty($api_secret) || empty($access_token) || empty($access_token_secret) || empty($basename)) { return 0; } $tumblr = new Tumblr($api_key, $api_secret, $access_token, $access_token_secret); $response = $tumblr->followers($basename); if (!$response || !is_object($response)) { return 0; } if (isset($response->response) && isset($response->response->total_users)) { return $response->response->total_users; } }