title: How do I access the XML from a flickr.photos.search API call?
body: <p>My client's system needs to access private photos from their Flickr account using the flickr.photos.search API call. I set it up and got the generated URL for that call. When I visit that URL in the browser, it outputs XML like it should.</p>
  
  <p>(API reference: <a href="http://www.flickr.com/services/api/flickr.photos.search.html" rel="nofollow noreferrer">http://www.flickr.com/services/api/flickr.photos.search.html</a>)</p>
  
  <p>However, in PHP I want to access that XML and display it using the simplexml PHP extension. I can't figure out how to access the XML, since it's not sitting in a .xml file but rather in a dynamic URL.</p>
  
  <p>The XML file (from the browser) looks like this: </p>
  
  <pre><code>&lt;rsp stat="ok"&gt;
    &lt;photos page="1" pages="1" perpage="100" total="4"&gt;
      &lt;photo id="4332852622" owner="36520372@N05" secret="xxxxxxxx" server="2760" farm="3" title="building" ispublic="0" isfriend="0" isfamily="0"/&gt;
      &lt;photo id="4332113745" owner="36520372@N05" secret="xxxxxxx" server="2803" farm="3" title="digging" ispublic="0" isfriend="0" isfamily="0"/&gt;
      &lt;photo id="4332852444" owner="36520372@N05" secret="xxxxxxx" server="4025" farm="5" title="house" ispublic="0" isfriend="0" isfamily="0"/&gt;
      &lt;photo id="4332113699" owner="36520372@N05" secret="xxxxxxx" server="2802" farm="3" title="PaulLuomaHab" ispublic="0" isfriend="0" isfamily="0"/&gt;
    &lt;/photos&gt;
  &lt;/rsp&gt;
  </code></pre>
  
  <p>And with PHP I'm trying this:</p>
  
  <pre><code>$rsp = simplexml_load_file($flickrURL);
  foreach($rsp-&gt;photos-&gt;photo as $photo) {
      echo $photo-&gt;title;
  }
  </code></pre>
  
  <p>It returns nothing at all. Am I missing something here?</p>
  
  <p><strong>NOTE:</strong> I added <code>echo "Ding!";</code> inside of the <code>foreach</code> loop above, and it DOES echo Ding!Ding!Ding!Ding!, which means it's recognizing there are 4 photos and looping through the right number of times. </p>
  
  <p>So apparently it's just not happy with $photo->title for some reason?</p>
  
  <p><strong>Also</strong></p>
  
  <p>When I use <code>print_r($photo)</code> I get this: </p>
  
  <pre><code>SimpleXMLElement Object ( [@attributes] =&gt; Array ( [id] =&gt; 4332852622 [owner] =&gt; 36520372@N05 [secret] =&gt; 88fff62f43 [server] =&gt; 2760 [farm] =&gt; 3 [title] =&gt; building [ispublic] =&gt; 0 [isfriend] =&gt; 0 [isfamily] =&gt; 0 ) )
  </code></pre>