Coder Social home page Coder Social logo

tumblr-grabbr-for-laravel's Introduction

Tumblr_grabbr

Grab Tumblr posts

Note

To avoid implementing entire OAuth flow, Tumblr_grabbr uses Tumblr API v1. Please note that this lib can be broken any time when they decide to deprecate old API.

Requirements

Installation

  • Copy tumblr_grabbr.php to libraries folder

Basic usage

  • fetch 10 posts from demo.tumblr.com using cache (if available)

      $page = Input::get('page', 1);
      $data = Tumblr_grabbr::grab('demo', $page, 10);
      if ($data){ ... }
    
  • You can turn off cache by passing 4th argument FALSE

      $data = Tumblr_grabbr::grab('demo', 1, 10, FALSE);
    
  • Configured your Tumblr using your own domain?

      $data = Tumblr_grabbr::grab('http://yourwebsite.com', 1, 5);
    
  • fetch single post from demo.tumblr.com

      $post = Tumblr_grabbr::grab_one('demo', 192341);
      if ($post){ ... }
    

View

$data = Tumblr_grabbr::grab('demo', 1, 10);
return View::make('blog_listing')->bind('data', $data);

In your blog_listing.php view file, play with $data['posts']

foreach ($data['posts'] as $post)
{
	// print_r($post);
}

Post type & properties

See Tumblr API v1 docs

Pagination

Tumblr_grabbr utilizes Laravel's Paginator class.

$data = Tumblr_grabbr::grab('demo', 1, 10);

if ($data['pagination')
{
	echo $data['pagination']->links();

	// ...or...
	// echo $data['pagination']->previous();
	// echo $data['pagination']->next();
}

Summary, Thumbnail support

Tumblr_grabbr::grab adds summary and thumbnail-url property to every text type post.

  • The First two paragraphs(<p>) becomes summary (if available)
  • URL of the first image(<img>) becomes thumbnail-url (if available)

this is the reason why I made Tumblr_grabbr :/

tumblr-grabbr-for-laravel's People

Contributors

mywizz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.