My favorites | Sign in
Project Home Downloads Wiki Issues
Search
for
Documentation  
It's easy, I promise :) .
Featured, Phase-Implementation
Updated Mar 28, 2011 by my.name....@gmail.com

Read functions

Here are docs for all the read functions. It's soooo easy to read the informations from a tumblelog uning phpTumblr that I think a doc is useless... But here it is!

Creating the object

So, at first, you have to create the readTumblr object. That simple:

$tumblrObj = new readTumblr('mytumblelog');

Where mytumblelog is the ID of your tlog on Tumblr (the part before tumblr.com in it's URI).

Get some posts

Now, the main function of phpTumblr: getPosts. You can get posts with many parameters. You want your 10 last videos? Your 3 last audios starting from the 15th ? No problem :) .

Here's the syntax:

$tumblrObj->getPosts($start,$num,$type,$id);

Let's see the params:

  • $start: the number of posts after that you'll get those you want. Default is 0.
  • $num: the number of posts you want to get. Default is 20.
  • $type: the type of posts you want to get. Valid types are regular, quote, photo, link, conversation, video and audio. Default is null (all types will be taken).
  • $id: if you want to get a specific post, it's ID go here. Default is null (not used).

And finally get it!

No more ceremony...

$tumblrArr = $tumblrObj->dumpArray();

Now I think you could print_r that array and see what you can do with it ;) . That's all!

Enable Caching

phpTumblr support caching so you can save bandwith and stop bombing Tumblr. It's simple as well! Remember when we create the Object?

$tumblrObj = new readTumblr('mytumblelog');

Just create a readTumblrCache object!

$tumblrObj = new readTumblrCache('mytumblelog','path/to/tmp',3600);

The first param have not changed. The second is the path to you cache directory. Be sure you webserver can write in! The last param is the time in second before refreshing the cache. 3600s = 1h. But you can put whatever you want ;) .

Comment by appleca...@gmail.com, Dec 23, 2008

great work!thanks for teaching

Comment by jason.co...@gmail.com, May 16, 2009

Just thought I'd point out that this documentation doesn't quite work with the updated package. The comments in the example files included with the download explain everything, though!

Comment by project member my.name....@gmail.com, May 17, 2009

Yeah, I've didn't updated here yet... But the example.php is hopefully clear enough.

Comment by timan...@gmail.com, Jun 17, 2009

bless your soul! Kind sir!!!!

Comment by Benjamin...@gmail.com, Feb 22, 2010

i dont really get it. is this kind of like a hack before they released the api. what is your code for. i;m looking for documentation to work with the api. can you give me a broad view for more of a beginner... right now i am using the api and only want to read, but having trouble with blogs that are hosted on non .tumblr.com domains.

any advice on where to start?

Comment by jaked...@gmail.com, May 13, 2010

Love it! Thank you so much.

Comment by nickhoa...@gmail.com, May 20, 2010

Does anyone have any examples of how to loop through the array and echo the title and content to the screen? I'm having trouble with the time/id portion of my loop. Thanks!

Comment by josephme...@gmail.com, May 24, 2010

//use foreach like this one

foreach($aTumblr['posts'] as $key => $val){

print $val['content']['title'].''.$val['content']['body'];
}

Comment by josephme...@gmail.com, May 24, 2010

<code> foreach($aTumblr['posts'] as $key => $val){ print $val['content']['title'].''.$val['content']['body']; } </code>

Comment by josephme...@gmail.com, May 24, 2010

sorry it seems we cannt post a "[" and "]" the question mark u see, must be "[" and "]"

Comment by josephme...@gmail.com, May 24, 2010

Can we categorized the post?

Comment by ajec4...@gmail.com, May 25, 2010

you Should c",)

Comment by turbo@mechanicalape.com, Sep 29, 2010

is there an example of embedding the php?

Comment by J.Dewi...@gmail.com, Nov 27, 2010

Anyone know why when $start is set to NULL or 0, it still skips the first post?

Comment by project member my.name....@gmail.com, Nov 27, 2010

http://tumblr.saymonz.net/read/demo/debug.txt?start=0&num=all No post skipped. On which site have you see this problem?

Comment by federico...@yahoo.it, Jun 20, 2011

Sorry... is there a way to retrieve "queued" posts?

thanks

Comment by thongoc2...@gmail.com, Jul 15, 2011

How to add a new post TumblrAPI V2, help me :(

Comment by thongoc2...@gmail.com, Jul 15, 2011

$request_data = http_build_query(

array(
'oauth_token' => 'xxx', 'api_key' => 'xxx', 'type' => 'hello', 'title' => 'this is title', 'body' => 'this is body', 'generator' => 'API example'
)
);

// Send the POST request (with cURL) $c = curl_init('http://api.tumblr.com/v2/blog/denui.tumblr.com/post'); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $request_data); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($c); $status = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c);

--> not run Please help me!

Comment by ilovelig...@gmail.com, Nov 7, 2011

Hi!

I have 2 posts total.

For some reason, it's only pulling 1 post when I have: $oTumblr->getPosts(0,5, null, null);

When I do: $oTumblr->getPosts(1,5, null, null); it pulls the second post.

Any ideas why this would happen?

Thanks!!!!!!

Comment by macke...@gmail.com, Jan 27, 2012

I was getting write errors when trying the cache-ing technique and was able to get them to go away by hard coding my tmp directory in class.read.tumblr.cache.php . I don't have time to reverse engineer this (awesome) library but I thought I would let you guys know.


Sign in to add a comment
Powered by Google Project Hosting