Quantcast
Channel: PHP - Get image url from RSS feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

PHP - Get image url from RSS feed

$
0
0

I have to get the url (not the link) of an image that I'm getting from an rss feed in PHP. I know that if I want to get the link (not url) of one of the feed titles I have to use $feed->channel->item->link; but what if I want to get the image url (not the link) of the feed item and insert it into a variable for later use? maybe $feed->channel->image->url; - i used this but nothing works.

This is what I used to get the feed.

function get_google_image($image){{        $intento=0;         $imagealt=get_the_title(); //its wordpress         $image=get_the_title();                 $words = explode("", $image);                 $imagetitle = implode("", array_splice($words, 0, 2));                 $image = implode("", array_splice($words, 0, 2));         $image=str_replace("","+",$image);         while (!$feed=simplexml_load_file("http://obsrv.com/General/ImageFeed.aspx?'$image'")){                 $attempt+=1;                 if ($attempt>5) break;                 print "Retry".$attempt."<br>";                 }                 $imagelink=$feed->channel->image->url; //Here is the problem, this variable finally gets empty and i want it to be the url of the image so i can post it with html later in the line below                 echo '<img title="' . $imagetitle . '" alt="' . $imagealt . '" src="' . $imagelink . '"/>';}}

The feed is http://obsrv.com/General/ImageFeed.aspx? (here the variable with the keyword for the image search) I want to get the first item from the rss feed list (the first image because every rss post has a only one image and also has a this image as an file attached to the post if it that helps you to help me). So I want to get this image and take out the url into a variable so then I can make a html code for posting an image.

echo '<img title="' . $imagetitle . '" alt="' . $imagealt . '" src="' . $imagelink . '"/>';

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images