hackvish Posted December 2, 2010 Share Posted December 2, 2010 I'm trying to Embed the images from Apple into my PHP file. $phpobj = unserialize($response); if (is_array($phpobj)) { foreach ($phpobj['value']['items'] AS $key => $val) { printf("<div><p><a href=%s>%s</a></p><p>%s</p>\n", $val['link'], $val['title'], $val['description']); } } But the problem is that the image attribute is inside a Table and using something lile $val['img'] is not working. So anybody can help me with this. Here is the RSS feed format from which I'm importing <item> <title>Dead Awake - Trailer</title> <link>http://trailers.apple.com/trailers/independent/deadawake/</link> <description>DEAD AWAKE is a seductive supernatural thriller starring Rose McGowan, Amy Smart and Nick Stahl set against the backdrop of a mysterious tragedy that shattered their lives a decade ago and which sets them on a path to uncover the truth that lies between the living and the dead.</description> <pubDate>Wed, 01 Dec 2010 00:00:00 PST</pubDate> <content:encoded><![CDATA[ <table> <tr valign="top"> <td width="67"><a href="http://trailers.apple.com/trailers/independent/deadawake/"><img src="http://trailers.apple.com/trailers/independent/deadawake/images/poster.jpg" width="65" height="97" border="0"></a></td> <td> </td> <td><a href="http://trailers.apple.com/trailers/independent/deadawake/"><span style="font-size: 16px; font-weight: 900; text-decoration: underline;">Dead Awake - Trailer</span></a><br /> <span style="font-size: 12px;">DEAD AWAKE is a seductive supernatural thriller starring Rose McGowan, Amy Smart and Nick Stahl set against the backdrop of a mysterious tragedy that shattered their lives a decade ago and which sets them on a path to uncover the truth that lies between the living and the dead.<br /><b>Directed by:</b> Omar Naim<br /><b>Starring:</b> Nick Stahl, Rose McGowan, Amy Smart, Ben Marten, Kim Grimaldi, Brian Lynner, Justin Marxen, James Serpento, Jack Mishler, Shane Simmons, Rachel Storey, Justin Urich, Andrea Leon, Livia Milano, Phyllis Mumford</span></td> </tr> </table> ]]></content:encoded> </item> Quote Link to comment https://forums.phpfreaks.com/topic/220434-embedding-images-from-rss-into-php/ Share on other sites More sharing options...
JakeTheSnake3.0 Posted December 2, 2010 Share Posted December 2, 2010 If you can count on the image being a JPEG then you might be able to get away with using regular expressions to extract the URL from the description. Use the $val['link'] variable inside the regular expression search string as the jpeg URL seems to reside in the same directory. Quote Link to comment https://forums.phpfreaks.com/topic/220434-embedding-images-from-rss-into-php/#findComment-1142099 Share on other sites More sharing options...
hackvish Posted December 2, 2010 Author Share Posted December 2, 2010 But the problem is that the image attribute is within the embed field. So I'm not able to use it. The link, title and description can be used directly as $val['link'], $val['title'], $val['description'] but how can I use the Image?? Any help??? Quote Link to comment https://forums.phpfreaks.com/topic/220434-embedding-images-from-rss-into-php/#findComment-1142136 Share on other sites More sharing options...
OldWest Posted December 2, 2010 Share Posted December 2, 2010 You might be able to use the php DOM Parser extension.. You can extract all img tags and grap the url and contents like so... Not sure if it will work with your RSS, but you might want to look into it. Quote Link to comment https://forums.phpfreaks.com/topic/220434-embedding-images-from-rss-into-php/#findComment-1142144 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.