Tyssen Posted July 9, 2019 Share Posted July 9, 2019 I'm working with an XML feed which provides image URLs that I want to save to an images field in a repeater. So far I have this: foreach($page->goodreads as $goodreads) : $xml_string = $cache->get($goodreads->isbn, 3600, function() use($goodreads_api, $goodreads) { return curl_get_contents('https://www.goodreads.com/search/index.xml?key='.$goodreads_api.'&q='.$goodreads->isbn); }); $book_xml = new SimpleXMLElement($xml_string); foreach ($book_xml->search->results->work as $book) : $goodreads->of(false); $goodreads->images->add($book->best_book->image_url); $goodreads->save(); $goodreads->of(true); endforeach; endforeach; I've tested that $book->best_book->image_url does actually return a value and have also tested the above with a hard-coded image URL but in both cases, no image is saved. What am I missing? Link to comment Share on other sites More sharing options...
Tyssen Posted July 10, 2019 Author Share Posted July 10, 2019 Figured it out in the end. Coded above would work fine, but I had other conditionals in place which were preventing parts of it from running. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now