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 ;) .
great work!thanks for teaching
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!
Yeah, I've didn't updated here yet... But the example.php is hopefully clear enough.
bless your soul! Kind sir!!!!
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?
Love it! Thank you so much.
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!
//use foreach like this one
foreach($aTumblr['posts'] as $key => $val){
}<code> foreach($aTumblr['posts'] as $key => $val){ print $val['content']['title'].''.$val['content']['body']; } </code>
sorry it seems we cannt post a "[" and "]" the question mark u see, must be "[" and "]"
Can we categorized the post?
you Should c",)
is there an example of embedding the php?
Anyone know why when $start is set to NULL or 0, it still skips the first post?
http://tumblr.saymonz.net/read/demo/debug.txt?start=0&num=all No post skipped. On which site have you see this problem?
Sorry... is there a way to retrieve "queued" posts?
thanks
How to add a new post TumblrAPI V2, help me :(
$request_data = http_build_query(
);// 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!
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!!!!!!
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.