Jump to content

Embedding Images from RSS into PHP


hackvish

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/220434-embedding-images-from-rss-into-php/
Share on other sites

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.

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???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.