title: Using PHP to get Tumblr Photo
body: <p>EDIT: Figured out a solution. As was suggested, I converted the script to use the JSON instead of the XML. The script is as follows and should work inside a Wordpress install if needed</p>
  
  <pre><code>    &lt;?php
  $offset = $_GET['offset'];
  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL,"http://blog.dgovil.com/api/read/json?num=10&amp;start=".$offset);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  $result = curl_exec($ch);
  curl_close($ch);
  
  $result = str_replace("var tumblr_api_read = ","",$result);
  $result = str_replace(';','',$result);
  $result = str_replace('\u00a0','&amp;amp;nbsp;',$result);
  
  $jsondata = json_decode($result,true);
  $posts = $jsondata['posts'];
  
  
  foreach($posts as $post){   ?&gt;
  &lt;div class="tumblr_post post-&lt;?php echo $post['type'] ?&gt;"&gt;
  
      &lt;?php if ($post['type'] == 'regular') { ?&gt;
          &lt;div class="post-title" id="post-&lt;?php echo $post['id'];?&gt;"&gt;&lt;a href="&lt;?php echo $post['url-with-slug']; ?&gt;"&gt;&lt;?php echo $post{'regular-title'}; ?&gt;&lt;/a&gt;&lt;/div&gt;
      &lt;?php echo $post{'regular-body'}; ?&gt;
        &lt;?php } ?&gt;
  
      &lt;?php if ($post['type'] == 'quote') {  ?&gt;
          &lt;?php echo $post{'quote-text'}; ?&gt;
          &lt;?php echo $post{'quote-source'}; ?&gt;
        &lt;?php } ?&gt;
  
  
      &lt;?php if ($post['type'] == 'photo') {  ?&gt;
          &lt;img src="&lt;?php echo $post['photo-url-500'];?&gt;"&gt;
          &lt;?php echo $post{'photo-caption'}; ?&gt;
          &lt;?php echo $post{'photo-set'}; ?&gt;
  
          &lt;a href="&lt;?php echo $post{'photo-url'}; ?&gt;" class="fImage"&gt;View Full Size&lt;/a&gt;
      &lt;?php } ?&gt;
  
      &lt;?php if ($post['type'] == 'link') {  ?&gt;
  
          &lt;p&gt;&lt;a href="&lt;?php echo $post{'link-url'}; ?&gt;"&gt;&lt;?php echo $post{'link-text'}; ?&gt;&lt;/a&gt;
          &lt;?php echo $post{'link-description'}; ?&gt;
        &lt;?php } ?&gt;
  
      &lt;?php if ($post['type'] == 'conversation') {  ?&gt;
          &lt;?php echo $post{'conversation-text'}; ?&gt;
        &lt;?php } ?&gt;
  
  
      &lt;?php if ($post['type'] == 'video') {  ?&gt;
          &lt;!--&lt;?php echo $post{'video-source'}; ?&gt;--&gt;
          &lt;?php echo $post{'video-player'}; ?&gt;
          &lt;?php echo $post{'video-caption'}; ?&gt;
        &lt;?php } ?&gt;
  
      &lt;?php if ($post['type'] == 'conversation') {  ?&gt;
          &lt;?php echo $post{'audio-caption'}; ?&gt;
          &lt;?php echo $post{'audio-player'}; ?&gt;
          &lt;?php echo $post{'audio-plays'}; ?&gt;
        &lt;?php } ?&gt;
  
  &lt;div id="post-date"&gt;
  &lt;?php echo date("jS D M, H:i",strtotime($post['date'])); ?&gt;&amp;nbsp; &amp;nbsp;&lt;a href="&lt;?php echo $post['url-with-slug']; ?&gt;"&gt;Read on Tumblr&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  
  
  
  &lt;?php   }?&gt;
  
  
  &lt;div id="tumblr_down"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  // load the api response
  $.getJSON('http://tumblruptime.apigee.com/json?callback=?', function (response) {
      // check if an api method is broken
      if (!response.methods['/api/read'].up) {
          $('#tumblr_down').text('Tumblr seems to not want to work with me right now. You can still try and view the posts on blog.dgovil.com. Service provided by http://tumblruptime.icodeforlove.com/apiinfo');
      }
  });
  &lt;/script&gt;
  
  &lt;div id="tumblr_postnav"&gt;
  &lt;a href="&lt;?php echo '?offset='.($offset + 10) ?&gt;" id="tumblr_next"&gt;Older posts&lt;/a&gt;
  &lt;a href="&lt;?php echo '?offset='.($offset - 10) ?&gt;" id="tumblr_prev"&gt;Newer Posts&lt;/a&gt;  
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks!</p>