In localhost (using Wamp on windows). I’m trying to use this:
<?
$xml = simplexml_load_file(‘http://stocklamp.tumblr.com/api/read/xml’);
$posts = $xml->xpath(“/tumblr/posts/post[@type=’regular’]”);
foreach($posts as $post) {?>
<?echo $post[‘id’];?>
<?echo $post[‘url-with-slug’];?>”>
<?echo $post->{‘regular-title’};?>
<?echo $post->{‘regular-body’};?>
<?echo date(“jS D M, H:i”,strtotime($post[‘date’]));?>
<?}?>
When trying, all I see is this on my site:
xpath(“/tumblr/posts/post[@type=’regular’]”); foreach($posts as $post) { ?> ”> {‘regular-title’};?> {‘regular-body’};?>
I found the snippet here:
http://stocklamp.tumblr.com/post/274675902/putting-your-tumblr-posts-on-your-websites-the-easy-way
Edit: fixed. Now I’m getting
Parse error: syntax error, unexpected ‘:’ in
C:\wamp\www..\index.php on line 52
and it is this line:
$xml =
simplexml_load_file(‘http://stocklamp.tumblr.com/api/read/xml’);
I keep getting this error: http://codepad.org/7f1IejIG
Okay. Now I go that fixed, but how do I get the posts by tag?
changing ‘type=…’ doesn’t work.
$posts = $xml->xpath("/tumblr/posts/post[@type='file']");
The last problem is to resolve is that the API XML url provided on the blog is not right. The following works:
http://jfcoder.com/test/tumblrtest.php
EDIT
Try running this code without the tags interspersed: